Heim  >  Artikel  >  Backend-Entwicklung  >  assemblyinfo.cs C# Assembly类访问程序集信息

assemblyinfo.cs C# Assembly类访问程序集信息

WBOY
WBOYOriginal
2016-07-29 08:40:031380Durchsuche

C#中通过Assembly类可以访问程序集信息.
1.允许访问给定程序集的元元素,包含可以加载和执行程序集的方法;
2.加载程序集:使用静态方法Assembly.Load(程序集名称)或Assembly.LoadFrom(程序集完整路径名);
3.属性:
FullName:程序集显示名称;
3.方法:
GetTypes():获取程序集中定义的类型。
TestAssembly.cs:
view plaincopy to clipboardprint?
using System; using System.Reflection;
namespace Magci.Test.Reflection
{ public class TestAssembly
{ public static void Main()
{ //将程序集加载到运行过程中
Assembly ass = Assembly.Load("TestCustomAttributes");
Assembly ass1 = Assembly.LoadFrom(@"E:\CODE\dotNet\C#\9-Reflection\TestCustomAttributes.dll");
//获取程序集显示名称
Console.WriteLine(ass1.FullName);
//获取程序集中定义的类型
Type[] types = ass.GetTypes();
foreach (Type t in types)
{ Console.WriteLine(t.FullName);
} } } }

以上就介绍了assemblyinfo.cs C# Assembly类访问程序集信息,包括了assemblyinfo.cs方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn