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抽象类基本用法。分享给大家供大家参考,具体如下: <?php //抽象类像一个模板,供子类扩展(重写),抽象类里有普通方法(有方法体),也有抽象方法...

php+ajax实现仿百度查询下拉内容功能示例

php+ajax实现仿百度查询下拉内容功能示例

本文实例讲述了php+ajax实现仿百度查询下拉内容功能。分享给大家供大家参考,具体如下: 运行效果如下: html代码: <!DOCTYPE html> <ht...

php数据类型判断函数有哪些

复制代码 代码如下: is_bool()、is_float()、is_int()、is_string()、is_object()、is_array() 和 is_integer()。...

PHP中使用Memache作为进程锁的操作类分享

<?php // 使用Memache 作为进程锁 class lock_processlock{ // key 的前缀 protected $sLoc...

php中Ioc(控制反转)和Di(依赖注入)

先看一个例子: <?php class A { public $b; public $c; public function A() { //TODO }...