↑ Grab this Headline Animator

Wednesday, May 14, 2008

How to load assembly from GAC?

Lets say you have to load the assembly from GAC on button click event then you should write following method.

protected void btn_Click(object sender, EventArgs e)


AssemblyName asm = new AssemblyName("ClassLibrary1, Version=, Culture=neutral,

Assembly al = Assembly.Load(asm);

Type t = al.GetType("ClassLibrary1.Class1");

MethodInfo m = t.GetMethod("Method1");

str = "reflection - " + (string)m.Invoke(null, null);



For more visit

Submit this story to DotNetKicks

1 comment:

Anonymous said...

if you already have the assembly in a different location, you may use its information (the file name) to load the assembly from GAC. what you need to do is, use "Assembly.Load" method without details of the file location. in this case, .NET CLR will look for the assembly in GAC automatically if it doesn't find it in a local folder. here's what you'd do:

FileInfo fi = new FileInfo(assembly);

Assembly asm = Assembly.LoadFrom(fi.Name);
asm = Assembly.Load(asm.ToString());

Post a Comment

Post your comments/questions/feedback for this Article.


Latest Articles