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


当前回答

只需转到发布->应用程序文件->,并将受影响的dll发布状态从先决条件改为包括! 这对我很管用!

其他回答

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

如果您更改了程序集版本或复制了错误中声明的托管库的不同版本,则以前编译的文件也可能引用了错误的版本。一个“重建所有”(或删除你的“bin”和“obj”文件夹在前面的评论中提到)应该解决这个问题。

为任何人添加我的解决方案,这可能会有所帮助。

I had a ClickOnce solution throwing this error. The app referenced a common "Libs" folder and contained a project reference to a Foo.dll. While none of the projects in the solution referenced the static copy of the Foo.dll in the "Libs" folder, some of the references in that folder did (ie: my solution had refs to Libs\Bar.dll which referenced Foo.dll.) Since the CO app pulled all the dependencies from Libs as well as their dependencies, both copies were going into the project. This was generating the error above.

我通过将我的Libs\Foo.dll静态版本移动到一个子文件夹Libs\Fix\Foo.dll来解决这个问题。此更改使ClickOnce应用程序只使用DLL的项目版本,并且错误消失了。

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

构建——>重建方案

只需转到发布->应用程序文件->,并将受影响的dll发布状态从先决条件改为包括! 这对我很管用!