令人沮丧、无意义的装配引用错误

发布于 2024-10-10 22:23:44 字数 1221 浏览 2 评论 0原文

我最近在一个相当大小的库上完成了 VB 到 C# 的转换(希望能成功)。但是,在尝试构建它时,我遇到了编译器带来的一些麻烦。我创建了一个名为 ExtensionMethods 的小型帮助程序库,对其进行编译,将 .dll 放入外围项目的 bin 文件夹中,并在新转换的文件中添加对它的引用图书馆。该库有两个命名空间:ExtensionMethods.JsonExtensionMethods.Enums。在我想要使用 Enums 命名空间的任何类中,我使用 using ExtensionMethods.Enums 导入它。我对 .Json 命名空间执行相同的操作(顺便说一句,效果很好)。

以下是所发生情况的图片证据:

alt text

注意 Enums 下的蓝色波浪线来自 Intellisense 的 Enums 同时建议。这是 VS 实际上识别程序集的证据(.ToInt() 是扩展方法的名称):

alt text

请注意 Intellisense 如何建议 .ToInt() 作为扩展方法,并且其下方没有波浪线,尽管据称...

替代文本 (三个文件使用此命名空间)

这是有意义的,除了...

alt text

本质上,这是什么意思“是的,Jason,您已经正确引用了所有程序集,是的,您的程序集包含了它们应该包含的命名空间,但是不,我今天不想编译。”

我只想编译并完成这个怪物。我在这里缺少什么?

UPDATE

ExtensionMethods.JsonExtensionMethods 中的另一个命名空间在引用时工作正常,不会产生程序集引用错误。这两个项目都是在同一台 64 位计算机上创建的,并且一切都以 .NET 4 为目标。

I've recently completed a (hopefully successful) VB to C# conversion on a decent-sized library. However, I am receiving some trouble from the compiler when trying to build it. I created a small helper library called ExtensionMethods, compiled it, dropped the .dll in the bin folder of the outlying project, and added a reference to it in the newly-converted library. The library has two namespaces, ExtensionMethods.Json and ExtensionMethods.Enums. In any class where I want to use the Enums namespace, I import it with using ExtensionMethods.Enums. I do the same for the .Json namespace (which works fine, by the way).

The following is picture evidence of what is happening:

alt text

Notice the blue squiggle under Enums with a simultaneous suggestion for Enums from Intellisense. Here is proof that VS actually recognizes the assembly (.ToInt() is the name of the extension method):

alt text

Notice how .ToInt() is both suggested by Intellisense as an extension method AND does not have a squiggle under it, even though ALLEGEDLY...

alt text
(three files use this namespace)

which would make sense, except for...

alt text

Essentially, what this is saying is that, "Yes, Jason, you have referenced all your assemblies correctly, yes, your assemblies contain the namespaces they should, but no, I don't feel like compiling today."

I just want to compile and be done with this monster. What am I missing here?

UPDATE

ExtensionMethods.Json, another namespace in ExtensionMethods works fine when referenced and does not produce an assembly reference error. Both projects were created on the same 64-Bit machine and everything targets .NET 4.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

凯凯我们等你回来 2024-10-17 22:23:44

这就是我修复它的方法。基本上,我从 bin 文件夹中删除了 .DLL,删除了对它的所有引用,将 .DLL 放回原处,然后重新引用了所有内容。现在,由于某种奇怪的原因,编译问题消失了。耶。

So here's how I fixed it. Basically I went and deleted .DLL from my bin folder, deleted every reference to it, dropped the .DLL back in, and re-referenced everything. Now, for some strange reason, that compilation problem is gone. Yay.

少女情怀诗 2024-10-17 22:23:44

当我在处理 64 位与 32 位问题时,我依稀记得类似的事情。确保该参考可供您的项目平台使用。如果我没记错的话,我在一个项目中引用了一个 32 位 DLL,该项目是为 64 位平台上的“任何 CPU”编译的,或者类似的东西,这是不久前的事了。

I vaguely remember something like this when I was struggling with a 64 vs 32 bit problem. Make sure the reference is usable by your project's platform. If I'm remembering correctly, I was referencing a 32-bit DLL in a project that was compiled for "Any CPU" on a 64-bit platform, or something of the sort, this was a while ago.

靑春怀旧 2024-10-17 22:23:44

当我遇到同样的问题时,我发现解决这个问题的唯一方法是注释掉所有这些内容和相关代码,删除引用,重新构建所有内容,再次添加引用并取消注释代码,重新构建。

注意:重新构建,而不是构建...并且仅重新添加引用并没有帮助

似乎构建器获得了无效的部分构建或其他内容(不知道它在技术上如何工作),甚至不会覆盖如果你告诉它重新构建。您需要删除所有代码和引用并重新构建以摆脱无效状态。

(是的,我知道,这是一项繁重的工作,而且很糟糕,但这是我发现摆脱它的唯一方法)

Only way to solve this I found when I had the same problem was commenting out all that and related code, removing the references, re-build all, adding the reference again and uncommenting the code, re-build.

note: re-build, not build... and just re-adding the reference doesn't help

It seems the builder gets an invalid partial build or something (don't know how it technically works) that it won't overwrite even if you tell it to re-build. You need to get rid of all the code and references and re-build to get rid of the invalid state.

(yes I know, it's a lot of work and it sucks, but it's the only way I found to get rid of it)

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