Namespace class conflict

First of all, I know that this is due to bad libraries, but I do not have code to fix them.

XXX.dll contains the Util class in the global namespace. Util.dll has a Util namespace.

When I include both DLL files, I cannot use the Util namespace (error 1. The namespace "Util" in ".. \ Util.dll" conflicts with the type "Util" in "\ XXX.dll").

Since both are in the global namespace, I don’t see how anti-aliasing can do this.

What is the best solution for this? At the moment, I know that I can make another .proj that will not contain both the DLL and the transfer classes that I need. But this is not easy to do, (

+4
source share
5 answers

You can use extern aliases for this - they allow you to efficiently qualify the link with which you mean. Anson Horton has a good walkthrough for them.

+11
source

Yes, there is a solution to your problem. Go to the References subfolder in your project, referencing the two assemblies. To build with global Util right-click and click Properties . You must have global Aliases property. Change this, for example, to DLL1 or whatever. Now, if you want to use the global Util in the file, add the following before the using statement:

extern alias DLL;

Now you can use a global Util similar to a DLL.Util

+9
source

You will need to use the language function "extern alias". Check out this Anson Horton blog post.

(Or just see John's answer).

+1
source

This error may also appear when updating the DevExpress project.

  • Close Visual Studio
  • Clean up the Temporary ASP.NET Files directories by cleaning 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\
    • Restart the World Wide Web Publishing (Start menu \ Settings> Control Panel \ Administrative Tools \ Services).
  • Empty the bin and obj folders and if necessary deploy new assemblies,

  • Restore your application
+1
source

Another way to fix this ... class files in folders inherit their namespace from the folder name. Make sure that all folders you add do not have the corresponding file name in the root of the same project.

0
source

Source: https://habr.com/ru/post/1389231/


All Articles