Warning “The type X in Y.cs conflicts with the imported type X in Z.dll”

后端 未结 9 973
Happy的楠姐
Happy的楠姐 2021-01-03 17:41

The main.cs of my project returns the following warning:

Warning 1 The type \'Extensions.MessageDetails\' in \'PATH\\Extensions.cs\'

相关标签:
9条回答
  • 2021-01-03 18:06

    I had this problem with a project that is also hosted on NuGet. I checked all project references. Finally, the object browser revealed that the DLL of an older version of my NuGet package was somehow loaded in Visual Studio from the NuGet cache folder ("C:\Users\{username}\.nuget\packages"). I removed the package from the cache folder, it disappeared from the object browser and everything was working fine again.

    0 讨论(0)
  • 2021-01-03 18:06

    I had faced same problem. Just a simple solution for that.

    Check your project references there must be same project reference. just remove that, it will work.

    0 讨论(0)
  • 2021-01-03 18:07

    I had a Shared Project, "Project A," which was included in both "Project B" and "Project C."

    "Project A" was added as a Shared Project in "Project B" and "Project C."

    "Project A" also included a traditional reference to "Project B."

    To correct the problem, I removed the reference to "Project B" from "Project A."

    0 讨论(0)
  • 2021-01-03 18:08

    In my case, with Visual Studio 2013, I found that one of my class libraries had developed a reference to itself. I think it happened when I added a new project to my solution or it was a bug, but either way it was causing this exact issue.

    Check your project references for any circular references.

    0 讨论(0)
  • 2021-01-03 18:13

    You can't have two copies of the extensions class, even though the code is the same they are not seen as the same object. Both your dll and main application will need to reference the exact same one.

    You could try creating a 'Common Files' class library and add the extensions class to it, that way you will always be using the correct class

    0 讨论(0)
  • 2021-01-03 18:19

    sometimes I get this error - it's a bug though in my case.. All I have to do to fix it is change the first letter of my script file name from upper case to lowercase in the file in Explorer / (or in Unity Engine in my case) and then change the name / class accordingly in my script. Idk why this happens.. just does - and Idk why this fix works .. but in my case it always does. - Otherwise you probably have 2 copies of the same script / same class name for 2 diff scripts. Hope this helps.

    0 讨论(0)
提交回复
热议问题