Referencing both an old version and new version of the same DLL (VB.Net)
Posted
by ckittel
on Stack Overflow
See other posts from Stack Overflow
or by ckittel
Published on 2010-04-08T03:22:35Z
Indexed on
2010/04/08
3:43 UTC
Read the original article
Hit count: 363
Consider the following situation:
WidgetCompany produced a .NET DLL in 2006 called Widget.dll, version 1.0. I consumed this Widget.dll file throughout my VB.Net application. Over time, WidgetCompany has been updating Widget.dll, I never bothered to keep up, continuing to ship version 1.0 of Widget.dll with my software. It's now 2010, my project is now a VB.Net 3.5 application and WidgetCompany has come out with Widget.dll version 3.0. It looks and functions almost identical to Widget.dll version 1.0, using all the same namespaces and type names from before.
However, Widget.dll version 3.0 has many run-time breaking changes since 1.0 and I cannot simply cut over to the new version; however, I don't want to continue developing against the 1.0 version and therefore keep digging myself deeper in the hole. What I want to do is do all new development in my project with Widget.dll version 3.0, whilst keeping Widget.dll version 1.0 around until I find time to convert all of my 1.0 consumption to the newer 3.0 code.
Now, for starters, I obviously cannot simply reference both Widget.dll (Ver 1.0) and Widget.dll (Ver 3.0) in Visual Studio. Doing so gives me the following message: "A reference to 'Widget.dll' could not be added. A reference to the component 'Widget' already exists in the project." To work around that, I can simply rename version 3.0 Widget.dll
to Widget.3.dll
. But this is where I'm stuck. Any attempts to reference types found in "the dll" leads to ambiguity and the compiler obviously doesn't have any clue as to what I really want in this or that case.
Is there something I can do that gives a DLL a new "root" Namespace or something? For example, if I could say "Widget.dll
has a new root namespace of Legacy
" then I could update existing code to reference the types found in Legacy.<RootNamespace>
namespace while all new code could simply reference types from the <RootNamespace>
namespace. Pipe dream or reality? Are there other solutions to situations this (besides "don't get in this situation in the first place")?
© Stack Overflow or respective owner