我试图使用c# 4.0编译我的excel插件,并在Visual Studio中构建我的项目时开始遇到这个问题。重要的是要告诉你,我以前从来没有遇到过这个问题。什么会导致这种情况发生?


当前回答

I recently hit this problem. In my case, I have NuGet packages on different assemblies. What I had was different versions of the same NuGet packages associated with my own assemblies. My solution was to use the NuGet package manager upon the Solution, as opposed to the individual projects. This enables a "consolidation" option, where you can upgrade your NuGet packages across as many projects as you want - so they all reference the same version of the assembly. When I did the consolidations, the build failure disappeared.

其他回答

请看这个答案。

转到发布页面,点击“应用程序文件”。从那里您应该会看到DLL的列表。确保那些给你带来麻烦的人的发布状态标记为“包括”而不是“先决条件”。

卸载和重新加载项目的问题解决了它为我。

这是在更改引用的.dll的版本时引起的。您需要删除目标构建文件夹中的所有项或.dll。

我得到类似的编译器错误。一旦我将dll文件的依赖项目添加到解决方案中,问题就解决了。

帮助我的是,我进入包管理器解决方案,查看导致问题的安装包。我看到有几个项目引用了相同的包,但是版本不同。我根据自己的需要把它们排列起来,这很有效。