本文整理汇总了C#中System.AppDomain.AssemblyLoad事件的典型用法代码示例。如果您正苦于以下问题:C# AppDomain.AssemblyLoad事件的具体用法?C# AppDomain.AssemblyLoad怎么用?C# AppDomain.AssemblyLoad使用的例子?那么, 这里精选的事件代码示例或许可以为您提供帮助。您也可以进一步了解该事件所在类System.AppDomain
的用法示例。
在下文中一共展示了AppDomain.AssemblyLoad事件的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.Reflection;
class Test {
public static void Main() {
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.AssemblyLoad += new AssemblyLoadEventHandler(MyAssemblyLoadEventHandler);
PrintLoadedAssemblies(currentDomain);
// Lists mscorlib and this assembly
// You must supply a valid fully qualified assembly name here.
currentDomain.CreateInstance("System.Windows.Forms, Version, Culture, PublicKeyToken", "System.Windows.Forms.TextBox");
// Loads System, System.Drawing, System.Windows.Forms
PrintLoadedAssemblies(currentDomain);
// Lists all five assemblies
}
static void PrintLoadedAssemblies(AppDomain domain) {
Console.WriteLine("LOADED ASSEMBLIES:");
foreach (Assembly a in domain.GetAssemblies()) {
Console.WriteLine(a.FullName);
}
Console.WriteLine();
}
static void MyAssemblyLoadEventHandler(object sender, AssemblyLoadEventArgs args) {
Console.WriteLine("ASSEMBLY LOADED: " + args.LoadedAssembly.FullName);
Console.WriteLine();
}
}