Browse Source

Forms designer is now reloading assemblies when required (based on patch by Alex Prudkiy).

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@978 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
8e182c7339
  1. 2
      data/resources/languages/LanguageDefinition.xml
  2. BIN
      data/resources/languages/bulgaria.png
  3. BIN
      data/resources/languages/czech.png
  4. 8
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Gui/CustomComponentsSideTab.cs
  5. 53
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeResolutionService.cs

2
data/resources/languages/LanguageDefinition.xml

@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
<!--<Languages name="Catalan" code="ca" page="" icon="catalonia.png" />-->
<!--<Languages name="Chinese (BIG5)" code="cn-big" page="" icon="chinalg.png" />-->
<Languages name="Chinese (GB)" code="cn-gb" page="" icon="chinalg.png" />
<!-- <Languages name="Czech" code="cz" page="" icon="czech.png" /> -->
<Languages name="Czech" code="cz" page="" icon="czech.png" />
<Languages name="Danish" code="dk" page="" icon="denmark.png" />
<Languages name="Dutch" code="nl" page="" icon="netherlands.png" />
<Languages name="Finnish" code="fi" page="" icon="finnish.png" />

BIN
data/resources/languages/bulgaria.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 931 B

BIN
data/resources/languages/czech.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 249 B

After

Width:  |  Height:  |  Size: 276 B

8
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Gui/CustomComponentsSideTab.cs

@ -81,7 +81,7 @@ namespace ICSharpCode.FormsDesigner.Gui @@ -81,7 +81,7 @@ namespace ICSharpCode.FormsDesigner.Gui
{
string className;
IProjectContent assemblyLocation;
bool initialized;
Assembly usedAssembly = null;
public CustomComponentToolBoxItem(IClass c)
{
@ -93,14 +93,12 @@ namespace ICSharpCode.FormsDesigner.Gui @@ -93,14 +93,12 @@ namespace ICSharpCode.FormsDesigner.Gui
void Init()
{
if (initialized)
return;
initialized = true;
LoggingService.Debug("Initializing MyToolBoxItem: " + className);
if (assemblyLocation != null) {
Assembly asm = TypeResolutionService.LoadAssembly(assemblyLocation);
if (asm != null) {
if (asm != null && usedAssembly != asm) {
Initialize(asm.GetType(className));
usedAssembly = asm;
}
}
}

53
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeResolutionService.cs

@ -16,10 +16,7 @@ using System.ComponentModel.Design; @@ -16,10 +16,7 @@ using System.ComponentModel.Design;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.Core;
using System.Diagnostics ;
using HashFunction = System.Security.Cryptography.SHA1Managed;
using System.Diagnostics;
namespace ICSharpCode.FormsDesigner.Services
{
@ -123,7 +120,10 @@ namespace ICSharpCode.FormsDesigner.Services @@ -123,7 +120,10 @@ namespace ICSharpCode.FormsDesigner.Services
if (pc.Project != null) {
return LoadAssembly(pc.Project.OutputAssemblyFullPath);
} else if (pc is ReflectionProjectContent) {
return LoadAssembly((pc as ReflectionProjectContent).AssemblyLocation);
if ((pc as ReflectionProjectContent).IsGacAssembly)
return LoadAssembly(new AssemblyName((pc as ReflectionProjectContent).AssemblyFullName), false);
else
return LoadAssembly((pc as ReflectionProjectContent).AssemblyLocation);
} else {
return null;
}
@ -136,19 +136,17 @@ namespace ICSharpCode.FormsDesigner.Services @@ -136,19 +136,17 @@ namespace ICSharpCode.FormsDesigner.Services
{
if (!File.Exists(fileName))
return null;
byte[] data = File.ReadAllBytes(fileName);
string hash;
using (HashFunction hashFunction = new HashFunction()) {
hash = Convert.ToBase64String(hashFunction.ComputeHash(data));
}
string hash = Path.GetFileName(fileName) + File.GetLastWriteTimeUtc(fileName).Ticks.ToString();
lock (assemblyDict) {
Assembly asm;
if (assemblyDict.TryGetValue(hash, out asm))
return asm;
LoggingService.Debug("Loading assembly " + fileName + " (hash " + hash + ")");
try {
asm = Assembly.Load(data);
asm = Assembly.Load(File.ReadAllBytes(fileName));
} catch (BadImageFormatException e) {
if (e.Message.Contains("HRESULT: 0x8013141D")) {
LoggingService.Debug("Get HRESULt 0x8013141D, loading netmodule");
//netmodule
string tempPath = Path.GetTempFileName();
File.Delete(tempPath);
@ -167,7 +165,7 @@ namespace ICSharpCode.FormsDesigner.Services @@ -167,7 +165,7 @@ namespace ICSharpCode.FormsDesigner.Services
if(p.ExitCode == 0 && File.Exists(tempPath)) {
byte[] asm_data = File.ReadAllBytes(tempPath);
asm = Assembly.Load(asm_data);
asm.LoadModule(Path.GetFileName(fileName), data);
asm.LoadModule(Path.GetFileName(fileName), File.ReadAllBytes(fileName));
}
} catch (Exception ex) {
MessageService.ShowError(ex, "Error calling linker for netmodule");
@ -180,6 +178,7 @@ namespace ICSharpCode.FormsDesigner.Services @@ -180,6 +178,7 @@ namespace ICSharpCode.FormsDesigner.Services
}
} catch (FileLoadException e) {
if (e.Message.Contains("HRESULT: 0x80131402")) {
LoggingService.Debug("Get HRESULt 0x80131402, loading mixed modes asm from disk");
//this is C++/CLI Mixed assembly which can only be loaded from disk, not in-memory
string tempPath = Path.GetTempFileName();
File.Delete(tempPath);
@ -206,7 +205,7 @@ namespace ICSharpCode.FormsDesigner.Services @@ -206,7 +205,7 @@ namespace ICSharpCode.FormsDesigner.Services
lock (designerAssemblies) {
if (!designerAssemblies.Contains(asm))
designerAssemblies.Add(asm);
designerAssemblies.Insert(0, asm);
}
assemblyDict[hash] = asm;
return asm;
@ -215,16 +214,21 @@ namespace ICSharpCode.FormsDesigner.Services @@ -215,16 +214,21 @@ namespace ICSharpCode.FormsDesigner.Services
public Assembly GetAssembly(AssemblyName name)
{
return GetAssembly(name, false);
return LoadAssembly(name, false);
}
public Assembly GetAssembly(AssemblyName name, bool throwOnError)
{
return LoadAssembly(name, throwOnError);
}
static Assembly LoadAssembly(AssemblyName name, bool throwOnError)
{
try {
Assembly asm = Assembly.Load(name);
lock (designerAssemblies) {
if (!designerAssemblies.Contains(asm))
designerAssemblies.Add(asm);
designerAssemblies.Insert(0, asm);
}
return asm;
} catch (System.IO.FileLoadException) {
@ -262,14 +266,6 @@ namespace ICSharpCode.FormsDesigner.Services @@ -262,14 +266,6 @@ namespace ICSharpCode.FormsDesigner.Services
return null;
}
try {
lock (designerAssemblies) {
foreach (Assembly asm in DesignerAssemblies) {
Type t = asm.GetType(name, false);
if (t != null) {
return t;
}
}
}
Type type = Type.GetType(name, false, ignoreCase);
@ -310,6 +306,17 @@ namespace ICSharpCode.FormsDesigner.Services @@ -310,6 +306,17 @@ namespace ICSharpCode.FormsDesigner.Services
}
}
}
if (type == null) {
lock (designerAssemblies) {
foreach (Assembly asm in DesignerAssemblies) {
Type t = asm.GetType(name, false);
if (t != null) {
return t;
}
}
}
}
if (throwOnError && type == null)
throw new TypeLoadException(name + " not found by TypeResolutionService");

Loading…
Cancel
Save