Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CS0436 compiler warning with a shared project

We have two solutions (C#, VS2015) that consist of a few projects. The Basic-Solution with namespace Wpf has some classes that are re-written in the More Advanced - Solution in the namespace Wpf.Advanced because the more advanced solution uses different data types for example.

Since every code-change in one of the classes, that are present in both solutions, needs to be rewritten in the second file, we decided to change the structure and use a shared project as a single place where the files should be located for both solutions.

We now use "usings" in combination with precompiler #if #else #endif blocks to merge the two files into one by changing the data types based on the project (via a compilation symbol ADVANCED).

Now to the problem:

Since some of our example projects need to reference both, the Wpf and the shared project we get the mentioned warnings CS0436 because some objects, that now exist in the shared project and in the namespace Wpf.

How can I resolve this issue? I mean, everything works, but no warning is better than any warning, thank you!

like image 897
Eru Iluvatar Avatar asked Jan 18 '26 05:01

Eru Iluvatar


1 Answers

I just had similar situation. In exe project I referenced dll and shared project. The dll in turn was referencing shared project. The solution was to exclude the shared project from the exe project. Since the shared project gets referenced from the dll the exe gets all of them too.
It may look trivial unless you are not experienced with shared projects.

like image 172
alehro Avatar answered Jan 19 '26 20:01

alehro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!