脚本宝典收集整理的这篇文章主要介绍了C# Assembly类访问程序集信息,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
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);
} } } }
以上是脚本宝典为你收集整理的C# Assembly类访问程序集信息全部内容,希望文章能够帮你解决C# Assembly类访问程序集信息所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。