Thursday, January 22, 2009

Activator.CreateInstance

According to the second reference, the Activator.CreateIntance is same as the "new" keyword.

To load the assembly from GAC:

System.Reflection.AssemblyName asmName = new System.Reflection.AssemblyName(name);
System.Reflection.Assembly asm = System.Reflection.Assembly.Load(asmName);
object
obj = asm.CreateInstance(typeName);

References:
(1)
http://blogs.msdn.com/haibo_luo/archive/2005/11/17/494009.aspx

(2)
Q&A of Activator.CreateInstance
http://bytes.com/groups/net-c/586685-activator-createinstance-question

(3)
http://mironabramson.com/blog/post/2008/08/Fast-version-of-the-ActivatorCreateInstance-method-using-IL.aspx

(4)
http://blog.lozanotek.com/archive/2006/03/22/8311.aspx

No comments:

Post a Comment