我试图使用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文件的依赖项目添加到解决方案中,问题就解决了。

就我而言,我将项目升级到。net 4.7.2,但仍然使用旧的visual studio版本(2015年)构建。 当我在VS 2019中构建项目时,构建失败消失了。

当我遇到这个问题时,我通过关闭“启用ClickOnce安全设置”来解决它。

菜单:项目|“项目名称”属性…|安全选项卡|“启用ClickOnce安全设置”复选框。

我也遇到了一些问题,我所要做的就是删除导致错误的.dll(可以在参考中找到),并重新添加它。

效果非常好。

请看这个答案。

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