ICSharpCode.ILSpy.AssemblyList.OpenAssembly C# (CSharp) Method

OpenAssembly() public method

Opens an assembly from disk. Returns the existing assembly node if it is already loaded.
public OpenAssembly ( string file, bool isAutoLoaded = false ) : LoadedAssembly
file string
isAutoLoaded bool
return LoadedAssembly
		public LoadedAssembly OpenAssembly(string file, bool isAutoLoaded=false)
		{
			//App.Current.Dispatcher.VerifyAccess();
			
			file = Path.GetFullPath(file);
			
			foreach (LoadedAssembly asm in this.assemblies) {
				if (file.Equals(asm.FileName, StringComparison.OrdinalIgnoreCase))
					return asm;
			}
			
			var newAsm = new LoadedAssembly(this, file);
			newAsm.IsAutoLoaded = isAutoLoaded;
			lock (assemblies) {
				this.assemblies.Add(newAsm);
			}

			return newAsm;
		}

Usage Example

示例#1
0
 void LoadInitialAssemblies()
 {
     // Called when loading an empty assembly list; so that
     // the user can see something initially.
     System.Reflection.Assembly[] initialAssemblies =
     {
         typeof(object).Assembly,
         typeof(Uri).Assembly,
         typeof(System.Linq.Enumerable).Assembly,
         typeof(System.Xml.XmlDocument).Assembly,
         typeof(System.Windows.Markup.MarkupExtension).Assembly,
         typeof(System.Windows.Rect).Assembly,
         typeof(System.Windows.UIElement).Assembly,
         typeof(System.Windows.FrameworkElement).Assembly,
         typeof(ICSharpCode.TreeView.SharpTreeView).Assembly,
         typeof(Mono.Cecil.AssemblyDefinition).Assembly,
         typeof(ICSharpCode.AvalonEdit.TextEditor).Assembly,
         typeof(ICSharpCode.Decompiler.Ast.AstBuilder).Assembly,
         typeof(MainWindow).Assembly
     };
     foreach (System.Reflection.Assembly asm in initialAssemblies)
     {
         assemblyList.OpenAssembly(asm.Location);
     }
 }
All Usage Examples Of ICSharpCode.ILSpy.AssemblyList::OpenAssembly