Warnings and Errors (CS0436, CS0234) when creating custom controls consisting of other custom controls in the same project

I am working on a Windows Forms solution with many winform ui projects. There is a class library project that contains some custom generic controls called MyControls .

Now, when I create a control in MyControls that consists of one or more controls in one project, I run into problems.

I either get compilation warnings: warning CS0436: The type "MyType" in "path-to \ MyType.cs" conflicts with the imported type "MyType" in "MyControls.dll". Using the type defined in 'path-to \ MyType.cs'. Or I get a bunch of different compilation errors, all pointing to "MyControls.dll" (error CS0234 - "do you miss the assembly link?").

I get either errors or warnings, neither one nor the other.

How to solve this?

Note

I added because of the version I came across. I do not know if this applies to other versions.

+4
source share
3 answers

I found that Visual Studio adds self-esteem to MyControls when I throw a control from a MyControls project onto another control in MyControls :

 <Reference Include="MyControls, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" /> 

My current workaround is to manually remove this link from MyControls.csproj using a text editor. When I did this, everything works fine until I drop another control that triggers self-awareness.

Best solutions appreciated!

+5
source

you can make a small and β€œlegal” change in your decision and get a β€œlegal” decision ... let's say your project name: "project01" go to the help folder in your project - one of your links called "project01" - just delete her ... warning is very fair! you create a form, and on the other hand import your project as a link!

+1
source

I know this thread is a bit outdated, but I was just looking for a solution to this problem, and it seems that MS has nothing but what Marijn previously suggested:

https://connect.microsoft.com/VisualStudio/feedback/details/613502/automatically-add-self-reference

Hope it was fixed in VS 2012.

0
source

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


All Articles