由于 VS 命名空间错误,找不到引用的 DLL
我有一个包含常见类型和例程的 DLL。程序集名称和命名空间相同:
MyCompany.Tools.Common
我添加对此 DLL 的引用,然后向希望使用程序集中的类型的文件添加 using 语句:
using MyCompany.Tools.Common;
然后我在另一个程序集中使用其中一种类型:
SafeInvoker.Invoke(this.pctBoxCLIP, delegate { this.pctBoxCLIP.Visible = value; });
到目前为止很好,但是当我现在尝试构建程序集时,Visual Studio 抱怨:
“类型或命名空间名称 “通用”不存在于 名称空间 'MyCompany.Tools'
但是,如果我查看对象浏览器,我可以看到命名空间 MyCompany.Tools.Common
&所有类型等。
如果我删除对 DLL 的引用并再次添加它,错误就会被删除,直到我尝试再次构建。
知道这里发生了什么以及如何解决它吗?
I have a DLL that contains common types and routines. The assembly name and namespace are the same:
MyCompany.Tools.Common
I add a reference to this DLL and then I add a using statement to a file that wishes to use a type from the assembly:
using MyCompany.Tools.Common;
I then use one of the types in another assembly:
SafeInvoker.Invoke(this.pctBoxCLIP, delegate { this.pctBoxCLIP.Visible = value; });
So far all good, however when I now try and build the assembly, Visual Studio complains that:
"The type or namespace name
'Common' does not exist in the
namespace
'MyCompany.Tools'
However, if I look in the Object Browser, I can see the namespace MyCompany.Tools.Common
& all the types etc.
If I remove the reference to the DLL and add it again the error is removed until I attempt to build again.
Any idea what is going on here and how to resolve it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
刚刚解决了完全相同的问题。我有一种使用 .NET Framework 4 Client Profile 编译的解决方案,另一种使用 .NET Framework 4(完整)编译的解决方案。
将两者更改为完整框架后,它开始工作。
Just solved exactly the same problem. I had one solution compiled with .NET Framework 4 Client Profile and the other one with .NET Framework 4 (Full).
After changing both to the Full framework, it started to work.
听起来好像每次你构建你的 dll 都会被替换。我昨天在 VS2010 中就遇到过这种情况。我删除了引用,从 bin 中删除了库,然后将两者添加回来,但它仍然发生。我所做的是删除引用,从 bin 文件夹中删除 dll,将最新版本的 dll 复制到新目录(与之前引用它的位置不同)并从新目录引用它。后来好像有工作了。至于为什么会发生,没有任何线索。
Sounds like every time you build your dll is getting replaced. I've had that happen to me just yesterday in VS2010. I removed the reference, deleted the library from bin, added both back and it still was happening. What I did was I removed the reference, deleted the dll from the bin folder, copied the latest version of the dll to a new directory (different from the location it was previously being referenced from) and referenced it from the new directory. Seemed to work afterwards. As to why it was happened, no clue.