views:

47

answers:

1

I need to be able to call utilities from different versions of the same assembly both residing in GAC:

gacutil /l TestAssembly  
  TestAssembly.dll, Version=1.0.0.0 ....  
  TestAssembly.dll, Version=2.0.0.0 ....  

And somewhere in code I need to dynamically load either one:

TestObject testObject;
if (loadFromVersion1)  
{  
    testObject = // instantiate test object from the first assembly  
}  
else  
{  
    testObject = // instantiate test object from the second assembly  
}  

Is there a way to do this without reflection (i know how to accomplish this with reflection) and use strongly typed objects instead?

+1  A: 

I think you are looking for extern alias.

GBegen
Thanks for the answer! I'm playing with extern alias now, but I get the following compile error: The extern alias 'TestAssembly_v2' was not specified in a /reference option In the compiler output it doesnt seem like it includes the second reference: D:\Windows\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /platform:x86 /reference:TestAssembly_v2=D:\Windows\assembly\GAC_MSIL\TestAssembly\2.0.0.0__21ba3456ad363211\TestAssembly.dll ...
kateroh
I don't think that gives me enough information to help you out. Perhaps a new question is in order with some more details, including a code sample and project settings.
GBegen