diff --git a/ILSpy/LoadedAssembly.cs b/ILSpy/LoadedAssembly.cs index 81f46e142..d0e3f182c 100644 --- a/ILSpy/LoadedAssembly.cs +++ b/ILSpy/LoadedAssembly.cs @@ -72,6 +72,28 @@ namespace ICSharpCode.ILSpy return AssemblyDefinition.ReadAssembly(fileName, p); } + [ThreadStatic] + static int assemblyLoadDisableCount; + + public static IDisposable DisableAssemblyLoad() + { + assemblyLoadDisableCount++; + return new DecrementAssemblyLoadDisableCount(); + } + + sealed class DecrementAssemblyLoadDisableCount : IDisposable + { + bool disposed; + + public void Dispose() + { + if (!disposed) { + disposed = true; + assemblyLoadDisableCount--; + } + } + } + sealed class MyAssemblyResolver : IAssemblyResolver { readonly LoadedAssembly parent; @@ -112,6 +134,8 @@ namespace ICSharpCode.ILSpy if (asm.AssemblyDefinition != null && fullName.Equals(asm.AssemblyDefinition.FullName, StringComparison.OrdinalIgnoreCase)) return asm; } + if (assemblyLoadDisableCount > 0) + return null; if (!App.Current.Dispatcher.CheckAccess()) { // Call this method on the GUI thread. diff --git a/ILSpy/TreeNodes/PropertyTreeNode.cs b/ILSpy/TreeNodes/PropertyTreeNode.cs index 24a12f0c7..2ead5dc71 100644 --- a/ILSpy/TreeNodes/PropertyTreeNode.cs +++ b/ILSpy/TreeNodes/PropertyTreeNode.cs @@ -36,7 +36,9 @@ namespace ICSharpCode.ILSpy.TreeNodes if (property == null) throw new ArgumentNullException("property"); this.property = property; - this.isIndexer = property.IsIndexer(); + using (LoadedAssembly.DisableAssemblyLoad()) { + this.isIndexer = property.IsIndexer(); + } if (property.GetMethod != null) this.Children.Add(new MethodTreeNode(property.GetMethod));