C# Assembly类访问程序集信息

yipeiwu_com6年前PHP代码库
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);
} } } }

相关文章

php返回当前日期或者指定日期是周几

PHP星期几获取代码: 复制代码 代码如下: date("l"); //data就可以获取英文的星期比如Sunday date("w"); //这个可以获取数字星期比如123,注意0是星...

设置php页面编码的两种方法示例介绍

1:输出meta标签: 1、在php mvc的控制器里面或php页面echo '<meta http-equiv="content-type" content="text/html...

PHP获取当前系统时间的方法小结

一、获取当前时间戳 方法1:通过time函数 time(); 方法2:通过$_SERVER中的REQUEST_TIME元素 $_SERVER['REQUEST_TIME']; 方...

PHP 可阅读随机字符串代码

复制代码 代码如下: /************** *@length - length of random string (must be a multiple of 2) *****...

让PHP支持页面回退的两种方法[转]

在开发过程中,往往因为表单出错而返回页面的时候填写的信息都不见了,为了支持页面回跳,可以通过两种方法实现。 第一,使用Header方法设置消息头Cache-control header(...