Browse Source

Fixed SD2-716: Forms Designer loads "hidden references" twice

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1373 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
ed672103f2
  1. 35
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeResolutionService.cs

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

@ -131,6 +131,11 @@ namespace ICSharpCode.FormsDesigner.Services @@ -131,6 +131,11 @@ namespace ICSharpCode.FormsDesigner.Services
}
}
static string GetHash(string fileName)
{
return Path.GetFileName(fileName).ToLowerInvariant() + File.GetLastWriteTimeUtc(fileName).Ticks.ToString();
}
/// <summary>
/// Loads the file in none-locking mode. Returns null on failure.
/// </summary>
@ -138,7 +143,16 @@ namespace ICSharpCode.FormsDesigner.Services @@ -138,7 +143,16 @@ namespace ICSharpCode.FormsDesigner.Services
{
if (!File.Exists(fileName))
return null;
string hash = Path.GetFileName(fileName) + File.GetLastWriteTimeUtc(fileName).Ticks.ToString();
// FIX for SD2-716, remove when designer gets its own AppDomain
foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) {
if (string.Equals(asm.Location, fileName, StringComparison.InvariantCultureIgnoreCase)) {
RegisterAssembly(asm);
return asm;
}
}
string hash = GetHash(fileName);
lock (assemblyDict) {
Assembly asm;
if (assemblyDict.TryGetValue(hash, out asm))
@ -214,6 +228,20 @@ namespace ICSharpCode.FormsDesigner.Services @@ -214,6 +228,20 @@ namespace ICSharpCode.FormsDesigner.Services
}
}
public static void RegisterAssembly(Assembly asm)
{
string file = asm.Location;
if (file.Length > 0) {
lock (assemblyDict) {
assemblyDict[GetHash(file)] = asm;
}
}
lock (designerAssemblies) {
if (!designerAssemblies.Contains(asm))
designerAssemblies.Insert(0, asm);
}
}
public Assembly GetAssembly(AssemblyName name)
{
return LoadAssembly(name, false);
@ -228,10 +256,7 @@ namespace ICSharpCode.FormsDesigner.Services @@ -228,10 +256,7 @@ namespace ICSharpCode.FormsDesigner.Services
{
try {
Assembly asm = Assembly.Load(name);
lock (designerAssemblies) {
if (!designerAssemblies.Contains(asm))
designerAssemblies.Insert(0, asm);
}
RegisterAssembly(asm);
return asm;
} catch (System.IO.FileLoadException) {
if (throwOnError)

Loading…
Cancel
Save