由于 VS 命名空间错误,找不到引用的 DLL

发布于 2024-11-01 02:39:33 字数 659 浏览 2 评论 0原文

我有一个包含常见类型和例程的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

纵情客 2024-11-08 02:39:33

刚刚解决了完全相同的问题。我有一种使用 .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.

じ违心 2024-11-08 02:39:33

听起来好像每次你构建你的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文