Here’s my problem:
I am using a DLL library (not from the .NET framework) which contains a System namespace with the Tuple and Lazy classes.
When I try to compile my project the compiler throws some errors stating that these classes exist in mscorlib.dll and another DLL.
So, how can I use the classes from the .NET Framework and don’t delete the reference to the other DLL?
If they have the same namespace etc, then the only way to disambiguate is to use an
extern alias. In the solution explorer, change theAliasesproperty of this rogue reference to something else, for examplefoo(instead ofglobal).Now, in the class files where you need types from that assembly, you’ll have to add (at the very top):
And then later down in the code you can use:
or equally:
Basically, the alias name becomes an extra level of disambiguation. The default alias, for reference, is
global. Note also, however, that while the compiler is fine with this, the VS2012 IDE still has a few… kinks withextern alias: https://connect.microsoft.com/VisualStudio/feedback/details/770464/ide-but-not-compiler-incorrectly-reports-an-error-when-using-extern-alias-to-disambiguate-types