C# Assembly类访问程序集信息
更新时间:2009年06月13日 00:08:35 作者:
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);
} } } }
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);
} } } }
相关文章
php通过header增加Key、Sign和Timestamp实现鉴权机制的流程步骤
在现代Web应用程序中,鉴权是确保只有合法用户能够访问资源的关键部分,在PHP中,你可以通过在HTTP请求的Header中添加Key、Sign和Timestamp来实现鉴权机制,需要的朋友可以参考下2023-10-10
最新评论