0

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 Answer 1

1

I think you are looking for extern alias.

Sign up to request clarification or add additional context in comments.

2 Comments

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 ...
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.