I am including an instance of the same source files in multiple assemblies using the Add As Link option. I specifically need to include an instance of the same source withi
I had a web application I converted from ASP.NET 3.5 to 4.5 when I moved to VS2015. I started seeing this as a warning, but the solution would still compile. There were no circular references, and cleaning the solution and deleting the bin
and obj
folders didn't help.
It turns out that VS2015 wasn't happy with some of my classes in the App_Code folder. The classes in here had the same namespace as the rest of the web pages in the parent folder. Once I moved these classes out of the App_Code folder and to the top level of the web application, the warnings went away.
The only time conflicts occur is when two dependent classes include the same class. There are two workarounds:
Disable the warning in classes that cause CS0436:
#pragma warning disable 0436
Have a separate instance of the class, uniquely named in each client project (undesirable from a maintenance point of view).
EDIT: There is also a solution: do what Mark suggests below, and mark duplicate classes internal
.
I had this error but not with 2 different classes!
Each new class where in conflict with itself, so obviously I had that CS0436 Error
.
After some struggling found out that it was about Mirror Asset
that I was using in my multiplayer Unity project. Mirror somehow was including every new class that I make (and inherit from NetworkBehavior
).
My external editor was VSCode
(visual studio code, solution might also apply to visual studio).
Solution
in
Edit / Preferences / External tools / "Generate .csproj files for:"
I started testing different settings, and this worked for me:
(Not sure if the exact settings work for all, but not having the right files in project, leads to this error. like my case.)
Click Regenerate project files
and restart Unity and VSCode after applying these settings (or the setting that suits your project).
In .NET Core you can also disable the warning in project.json:
{
"buildOptions":
{
"nowarn":
[
"CS0436"
]
}
}
It is worth noting that another way to get such warnings is by simply setting a project in visual studio to reference itself: References -> Solution -> etc etc (how I figured this gem out is left as an exercise to the reader ...)
Visual Studio will happily comply, only to throw a wall of warnings of the type described by OP during build, which is to be expected (upon reflection) since every single class etc is getting defined twice.