ProblemHave two versions of a DLL that use the same namespaces and class names.
Project compliation throws the following error:
The type 'MyNamespace.MyClass' exists in both 'MyDLLv1.dll' and 'MyDLLv2.dll'
error CS0433: The type 'MyNamespace.MyClass' exists in both 'MyDLLv1.dll' and 'MyDLLv2.dll'
SolutionUse an external assembly alias.
- Specify "Aliases" property of DLL reference.
- In Visual Studio Solution Explorer, open References folder.
- Right-click DLL reference, select Properties
- Enter alias value in "Aliases" property.
- Example: Alias to MyDLLv1.dll reference could be "LegacyMyDLL".
- Specify alias in C# source code:
// Old way
using MyNamespace;
// New way
extern alias LegacyMyDLL;
using LegacyMyDLL.MyNamespace;
Microsoft ReferencesNote: Could find no Microsoft references for specifying "Aliases" property of DLL reference within Visual Studio. Only for specifying compilation command line parameter."/reference (Import Metadata) (C#)." MSDN: Microsoft Development, MSDN Subscriptions, Resources, and More. 22 July 2009
http://msdn.microsoft.com/en-us/library/yabyz3h4(VS.80).aspx.
"Extern alias (C#)." MSDN: Microsoft Development, MSDN Subscriptions, Resources, and More. 22 July 2009
http://msdn.microsoft.com/en-us/library/ms173212(VS.80).aspx.
"How to: Use the Namespace Alias Qualifier (C#)." MSDN: Microsoft Development, MSDN Subscriptions, Resources, and More. 22 July 2009
http://msdn.microsoft.com/en-us/library/c3ay4x3d(VS.80).aspx.
Other References"What use is the Aliases property of assembly references in Visual Studio 8. -." Stack Overflow. 22 July 2009
http://stackoverflow.com/questions/286632/what-use-is-the-aliases-property-of-assembly-references-in-visual-studio-8.
"Enhancements in Assemblies and Versioning in Visual Studio 2005." C#, Visual Studio 2008, Silverlight, ASP.NET, WPF, WCF, WF, and Windows Vista Community. 22 July 2009
http://www.c-sharpcorner.com/UploadFile/rambab/Assembly04292006002740AM/Assembly.aspx?ArticleID=69edb807-8118-4933-8366-773e87ee80ad.