我试图使用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.

其他回答

如果依赖项不匹配,请在解决方案级别的NuGet包管理器中检查Update和consolidated选项卡,协调所有这些。

在我的解决方案中有太多的项目需要逐一检查和单独更新,所以我通过以下方法解决了这个问题:

右键单击我的解决方案并选择“管理解决方案的NuGet包…” 进入更新选项卡 找到受影响的包并选择Update 单击OK,这将使包的所有实例保持最新

请看这个答案。

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

在尝试了这里的大多数解决方案后,我最终只是从点击一次项目中添加了一个引用,这将它从包括更改为包括(自动),它最终工作了。

当我在更新WindowsAPICodePack后遇到这种情况时,我只是重新构建了解决方案。

构建——>重建方案