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 ;(
You need to use the global keyword. That forces the namespace resolution to start at the very top. It's mostly used in generated code to be doubly sure the right namespace is referenced. As an aside, it's probably best to avoid using System as a name of namespace.
Classes are data types. They are an expanded concept of structures, they can contain data members, but they can also contain functions as members whereas a namespace is simply an abstract way of grouping items together. A namespace cannot be created as an object; think of it more as a naming convention.
Two classes with the same name can be created inside 2 different namespaces in a single program. Inside a namespace, no two classes can have the same name. In C#, the full name of the class starts from its namespace name followed by dot(.)
The namespace keyword is used to declare a scope that contains a set of related objects. You can use a namespace to organize code elements and to create globally unique types.
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.
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
You will need to use the "extern alias" language feature. Check out this blog entry by Anson Horton.
(Or just see Jon's answer.)
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With