Reputation: 6967
First of all, I know that this is because of bad libraries, but I don't have code for them to fix this.
XXX.dll contains class Util in global namespace. Util.dll has namespace Util.
When I include both .dlls I can't use Util namespace (Error 1 The namespace 'Util' in '..\Util.dll' conflicts with the type 'Util' in '\XXX.dll').
Because both are in global namespace I don't see how aliasing can fix this.
What is best solution for this? For now i know that I can make another .proj which will not include both .dlls and wrap classes I need. But this is not easily done ;(
Upvotes: 5
Views: 3669
Reputation: 746
Another way to fix this ... class files in folders will inherit their namespace from the folders name. Make sure that any folders you add don't have a corresponding file name in the root of the same project.
Upvotes: 0
Reputation: 31237
This error may also show up when upgrading a DevExpress project
Visual Studio
Clear Temporary ASP.NET Files
directories by clearing the following folders:
C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\
C:\Users\[your_user_name]\AppData\Local\Temp\Temporary ASP.NET Files\
World Wide Web Publishing
service (Start menu\Settings\Control Panel\Administrative tools\Services).Clear the project's Bin and Obj folders and deploy new assemblies if it is necessary;
Upvotes: 1
Reputation: 3866
You will need to use the "extern alias" language feature. Check out this blog entry by Anson Horton.
(Or just see Jon's answer.)
Upvotes: 1
Reputation: 671
Yes, there is a solution to your problem. Go to the References
subfolder in your project referencing the two assemblies. For the assembly with the global Util
right click and press Properties
. In the Aliases
property you should have global
. Change that for example to DLL1
or whatever. Now if you like to use the global Util
in a file add the following before your using
statements:
extern alias DLL;
Now you can use the global Util
like that DLL.Util
Upvotes: 10
Reputation: 1499770
You should be able to use extern aliases for this - they allow you to effectively qualify a reference with which assembly you mean. Anson Horton has a good walkthrough for them.
Upvotes: 11