.NET Assembly

Load GAC Assembly

class  Program
    
{
        
static void Main(string[] args)
        
{
            
// 动态引用GAC的Assembly
            Assembly assembly = Assembly.Load("GACDemo,Version=1.0.0.0,Culture=neutral,PublicKeyToken=b821349f6886a4a6");
            Type type 
= assembly.GetType("GACDemo.Employee");
            Object employee 
= Activator.CreateInstance(type, new Object[] "Daniel""R&D"} );
            PropertyInfo NameProperty 
= type.GetProperty("Name");
            
string name = (string)NameProperty.GetValue(employee, null);
            PropertyInfo DeptProperty 
= type.GetProperty("Dept");
            
string dept = (string)DeptProperty.GetValue(employee, null);
            Console.WriteLine(
"Name: {0}, Dept: {1}", name, dept);
            Console.Read();
        }

    }

 

你可能感兴趣的:(assembly,.net,string,null,object,class,.NET,学习笔记)