当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > C#中通过Assembly类访问程序集信息

ASP.NET
ASP.NET在上传文件时对文件类型的高级判断的代码
JQuery运用ajax注册用户实例(后台asp.net)
Asp.net与SQLserver一起打包部署安装图文教程
asp.net 上传下载输出二进制流实现代码
asp.net(C#)解析Json的类代码
asp.net 截取字符串代码
asp.net ubb使用代码
asp.net XML文件操作实现代码
asp.net利用HttpModule实现防sql注入
ASP.NET(C#)中操作SQLite数据库实例
asp.net(c#)ref,out ,params的区别
asp.net(C#)防sql注入组件的实现代码
asp.net FCKeditor自定义非空验证
Asp.net TreeView来构建用户选择输入的方法 推荐
asp.net(C#)函数对象参数传递的问题
Asp.net中的GridView导出遇到的两个问题和解决方法
asp.Net 中获取一周第一天,一月第一天等实现代码
asp.net MaxLengthValidator 最大长度验证控件代码
C# 通用文件上传类
asp.net 自定义控件实现无刷新上传图片,立即显示缩略图,保存图片缩略图

ASP.NET 中的 C#中通过Assembly类访问程序集信息


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 93 ::
收藏到网摘: n/a

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);     
          }            }        }    }