In .NEt C# How can I tell the compiler to use a Type from a particular class when a second Type exists with the same name in my project references?
A class I wish to use exists in 2 project references.
The namespace etc is identical.
I require both references in the project, but for this particular class I wish to use the one from one of the references assemblies.
You use extern aliases. Anson Horton has a walkthrough here.
It’s a solution to a problem which you should avoid if at all possible, of course – but it does work.
Ironically enough, I’ve just been editing the section about extern aliases for the second edition of C# in Depth. Here’s the same code, where both First.dll and Second.dll expose a type called “Demo.Example”.