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

ASP.NET
ASP.NET编程中的十大技巧
ASP.NET常用函数(推荐)
ASP.NET上传图片并生成可带版权信息的缩略图
用javascript打造搜索工具栏
ASP.NET中动态控制RDLC报表
用ASP.NET还原与恢复Sql server
在ASP.NET里得到网站的域名
Asp.net中的mail的发送
用ASP.Net实现文件的在线压缩和解压缩
ASP.NET中文件上传下载方法集合
ASP.NET通过Remoting service上传文件
ASP.NET2.0服务器控件之Render方法
ASP.NET2.0新特性概述
asp.net2.0如何加密数据库联接字符串
用.NET 2.0压缩/解压功能处理大型数据
ASP.NET入门随想之检票的老太太
ASP与ASP.NET互通COOKIES的一点经验
ASP.NET2.0数据库入门之SqlDataSource
ASP.NET2.0数据库入门之SQL Server
ASP.NET 2.0下的条件编译

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 85 ::
收藏到网摘: 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);     
          }            }        }    }