Visual Studio adds a circular reference when I drag and drop a user control from the Toolbox

隐身守侯 提交于 2020-01-01 02:44:10

问题


I have a user control C that is defined inside project P. C is present as a ".NET Framework Component" in my Visual Studio Toolbox. I open a form F (also defined inside project P) and drop C onto F.

Once I do that drop, Visual Studio adds a reference under P pointing to P's own DLL. This is unnecessary and causes tons of build errors like The call is ambiguous between the following methods or properties... after which it lists the exact same method twice. If I go into References and delete the added reference, it builds correctly.

Can I prevent VS from adding this unnecessary reference?

Summary (By SLaks):
In VS2010, adding a UserControl to a form in the same project automatically adds a reference to the project itself, causing problems.


回答1:


As far as I know this has been around at least since visual studio 2008. I tried finding a possible fix back then, but could not find one. Sorry, but I think you cannot prevent the unnecessary reference and have to remove it every time it does that.




回答2:


I have had similar symptoms but I think the cause was different than what you describe. For me I kept implementing a class with a name that clashed with an existing class. This led to ambiguous call and other compiler hell breaking loose.

A simple rename cleared it up.



来源:https://stackoverflow.com/questions/3001380/visual-studio-adds-a-circular-reference-when-i-drag-and-drop-a-user-control-from

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!