當前位置: 首頁>>代碼示例>>C#>>正文


C# Assembly.Load方法代碼示例

本文整理匯總了C#中System.Reflection.Assembly.Load方法的典型用法代碼示例。如果您正苦於以下問題:C# Assembly.Load方法的具體用法?C# Assembly.Load怎麽用?C# Assembly.Load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Reflection.Assembly的用法示例。


在下文中一共展示了Assembly.Load方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Main

//引入命名空間
using System;
using System.Reflection;

class Class1
{
    public static void Main()
    {
        // You must supply a valid fully qualified assembly name.            
        Assembly SampleAssembly = Assembly.Load
            ("SampleAssembly, Version=1.0.2004.0, Culture=neutral, PublicKeyToken=8744b20f8da049e3");
        // Display all the types contained in the specified assembly.
        foreach (Type oType in SampleAssembly.GetTypes()) {
            Console.WriteLine(oType.Name);
        }
    }
}
開發者ID:.NET開發者,項目名稱:System.Reflection,代碼行數:17,代碼來源:Assembly.Load

示例2: Main

//引入命名空間
using System;
using System.Reflection;

public class Example
{
   public static void Main()
   {
      string longName = "system, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
      Assembly assem = Assembly.Load(longName);
      if (assem == null)
         Console.WriteLine("Unable to load assembly...");
      else
         Console.WriteLine(assem.FullName);
   }
}
開發者ID:.NET開發者,項目名稱:System.Reflection,代碼行數:16,代碼來源:Assembly.Load

輸出:

system, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

示例3: Main

//引入命名空間
using System;
using System.Reflection;

public class Example
{
   public static void Main()
   {
      String fullName = "sysglobl, Version=4.0.0.0, Culture=neutral, " +
                        "PublicKeyToken=b03f5f7f11d50a3a, processor architecture=MSIL";
      var an = new AssemblyName(fullName);
      var assem = Assembly.Load(an);
      Console.WriteLine("Public types in assembly {0}:", assem.FullName);
      foreach (var t in assem.GetTypes())
         if (t.IsPublic)
            Console.WriteLine("   {0}", t.FullName);
   }
}
開發者ID:.NET開發者,項目名稱:System.Reflection,代碼行數:18,代碼來源:Assembly.Load

輸出:

Public types in assembly sysglobl, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a:
System.Globalization.CultureAndRegionInfoBuilder
System.Globalization.CultureAndRegionModifiers

示例4: Assembly.Load(AssemblyName name2)

//引入命名空間
using System;
using System.Reflection;
using System.Globalization;

class MainClass
{
    public static void Main()
    {
        AssemblyName name2 = new AssemblyName();
        name2.Name = "System.Xml";
        name2.Version = new Version(2, 0, 0, 0);
        name2.CultureInfo = new CultureInfo("");    // Neutral culture.
        name2.SetPublicKeyToken( new byte[] {0xb7, 0x7a, 0x5c, 0x56, 0x19, 0x34, 0xe0, 0x89});
        Assembly a2 = Assembly.Load(name2);
    }
}
開發者ID:C#程序員,項目名稱:System.Reflection,代碼行數:17,代碼來源:Assembly.Load

示例5: Assembly.Load(String name)

//引入命名空間
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Reflection;
using System.Reflection.Emit;

public class MainClass
{
    public static void Main()
    {
        int x = 10;
        Assembly a = Assembly.Load("mscorlib");
        Type t3 = a.GetType("System.Int32");
        
        Type t1 = typeof(int);
        Type t2 = x.GetType();

        Type t4 = Type.GetType("System.Int32");

        Console.WriteLine(t1 == t2);
        Console.WriteLine(t2 == t3);
        Console.WriteLine(t3 == t4);
    }
}
開發者ID:C#程序員,項目名稱:System.Reflection,代碼行數:26,代碼來源:Assembly.Load


注:本文中的System.Reflection.Assembly.Load方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。