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


当前回答

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

其他回答

这里有一个不同的方法来解决这个问题:

右键单击项目并选择“卸载项目”选项。您将注意到您的项目变得不可用。 右键单击不可用项目并选择“Edit”选项。 向下滚动到包含所有资源标记的“< ItemGroup >”标记。 现在转到已经显示在错误列表中的引用,您将注意到它使用了单个标记(即< reference Include="assemble_name_here, Version=0.0.0.0, Culture=neutral" / >)。 更改为如下所示:

.

<Reference Include="assemble_name_here, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" >
    < Private > True < / Private >
    < HintPath > path_here\assemble_name_here.dll < / HintPath >
< / Reference >

保存您的更改,再次右键单击不可用的项目,然后单击“重新加载项目”选项,然后构建。

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

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

您需要使用密钥对程序集进行签名。进入选项卡签名下的项目属性:

您的程序集是否正确签名?

要检查这一点,在项目上按Alt+Enter(或右键单击,然后Properties)。点击“签名”。验证复选框“签名程序集”已选中,强名称密钥文件已选中,且“仅延迟签名”未选中。

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

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的项目版本,并且错误消失了。