↑ Grab this Headline Animator

Thursday, May 8, 2008

Can you place two .dll files with the same name in GAC (Global Assembly Cache)?

Yes, provided both have different versions.

GAC is a Folder that contains .dll that have strong name. So we can keep myproject.dll and myproject.dll two files into GAC with different version like and

You need to specify “bindingRedirect” in your config file. For instance in the below case “myproject.dll” has two versions “” and “” from which “” is the recent version. But using the bindingRedirect we can specify saying “” is the new version. So the client will not use “”.

Config file code:

In the above config file code we need to add publicKeyToken. To generate publicKeyToken use “sn –T myproject.dll”.

trick here is to notify the runtime to treat the newer version as older and older as newer

Lets say we have a method and in that method I want to use a function from the older assembly and another function from newer assembly. Is it possible?
Yes, It can be done.

private void btn_Click(object sender, EventArgs e)


string str = "early bind - ";

str += ClassLibrary1.Class1.Method1();


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);



Please read this

Submit this story to DotNetKicks

No comments:

Post a Comment

Post your comments/questions/feedback for this Article.


Latest Articles