Referencing shared project in several projects of solution

前端 未结 3 1733
有刺的猬
有刺的猬 2021-01-18 20:13

I am trying to fix warning

Warning CS0436: The type \'Class1\' in \'...\\SharedProject1\\SharedProject1\\Class1.cs\' conflicts with the imported type

3条回答
  •  长发绾君心
    2021-01-18 21:04

    Jarekczek's solution works fine when you have only one class library, but as soon as you add another class library which also references the shared project, you get the same warning again.

    The solution might be obvious, but if it's not here it is...

    You could create one more ordinary class library project named 'Common' which doesn't contain any classes on it's own, but only references shared project. It serves as a 'container' for shared code.

    So reference tree could look like this:

    SharedProject -> Common
    Common -> ClassLibrary1
    Common -> ClassLibrary2
    ClassLibrary1 -> Application
    ClassLibrary2 -> Application
    Common -> Application
    

提交回复
热议问题