Re: Multiple versions of the same type coexisting in the same AppD

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi Nicholas,

Thanks to you and all those who replied.
The extern alias solution matches my requirement very, very closely, that
sounds excellent news!

However, how would I be able to specify aliasing when loading the two
different DLL's in the AppDomain?

Thanks,
V.

"Nicholas Paldino [.NET/C# MVP]" wrote:

Vanni,

You can do this, but you have to know at compile time what the two
separate versions are. You would use the "extern alias" keywords, along
with a special way of referencing the dlls which contain the types when
calling the compiler (there is support in VS.NET for this too).

Take a look at the documentation for "extern alias" located at:

http://msdn2.microsoft.com/en-us/library/ms173212(VS.80).aspx

Anson Horton also has a walkthrough which will help:

http://blogs.msdn.com/ansonh/archive/2006/09/27/774692.aspx


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"Vanni" <Vanni@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C2C183FB-849A-4095-8BEE-73BAE93BCAD6@xxxxxxxxxxxxxxxx
Hello,

I have the requirement of being able to load different versions of the
same
type (same class name) in the executing AppDomain. I am aware that I would
not be able to unload obsolete instances, but I don't mind. The problem is
that, it seems, only one instance of the same class type can be present in
one particular AppDomain, and whatever attempt to load a class with the
same
name will result in the old instance being passed.

I would assume that a possible solution would be to have class names get
different names (eg. SampleClassName_{some Guid}) before being loaded, but
can I really do this hacking into a compiled DLL?

I have Googled around but couldn't find anything related to this. Any
ideas?

Thanks in advance, regards,
Vanni




.