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

ASP.NET
ewebeditor在.net的使用方法
Server.Transfer,Response.Redirect的区别
ASP.NET2.0+SQL Server2005构建多层应用
ASP.NET 2.0 中收集的小功能点(转)
ASP.Net全局变量的设置和读取方法
数据库开发总结(ADO.NET小结)
ASP.net(c#)打造24小时天气预报及实时天气
发布WEB站点时出现Server Application Unavailable
在asp.net中实现datagrid checkbox 全选的方法
ASP.NET 2.0 URL映射技巧
ConfiguraionSource节点及多个配置文件的应用
SqlConnection.ConnectionString相关关键字
如何在WebForm中使用javascript防止连打(双击)
看到本质而不是现象--解决ASP.NET CS0016的问题
学会区分Visual Studio 2005,Visual Studio 2005 Team System和MSDN Premium 订阅的各个版本
ASP.NET 入门的五个步骤
ASP.NET 高性能分页代码
动态ItemTemplate的实现(译) - item,template
遍历Hashtable 的几种方法
通过VS中的数据源选择对话框简单实现数据库连接配置

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


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