当前位置: 首页>>代码示例>>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;未经允许,请勿转载。