|
1.允許訪問給定程序集的元元素,包含可以加載和執(zhí)行程序集的方法;
2.加載程序集:使用靜態(tài)方法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技術(shù):C# Assembly類訪問程序集信息,轉(zhuǎn)載需保留來源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。