当我从工具箱拖放用户控件时,Visual Studio 添加了一个循环引用 [英] Visual Studio adds a circular reference when I drag and drop a user control from the Toolbox

查看:27
本文介绍了当我从工具箱拖放用户控件时,Visual Studio 添加了一个循环引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在项目 P 中定义的用户控件 C.C 在我的 Visual Studio 工具箱中作为.NET Framework 组件"存在.我打开一个表单 F(也在项目 P 中定义)并将 C 放到 F 上.

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.

一旦我这样做了,Visual Studio 在 P 下添加一个指向 P 自己的 DLL 的引用.这是不必要的,并且会导致大量构建错误,例如 The call is ambiguous between the following methods or properties... 之后它两次列出完全相同的方法.如果我进入参考并删除添加的参考,它会正确构建.

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.

我可以阻止 VS 添加这个不必要的引用吗?

Can I prevent VS from adding this unnecessary reference?

摘要(由 SLaks 提供):
在VS2010中,在同一个项目的表单中添加UserControl会自动添加对项目本身的引用,导致问题.

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.

推荐答案

我有类似的症状,但我认为原因与您描述的不同.对我来说,我一直在实现一个名称与现有类冲突的类.这导致了模棱两可的调用和其他编译器的崩溃.

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.

这篇关于当我从工具箱拖放用户控件时,Visual Studio 添加了一个循环引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆