我试图使用c# 4.0编译我的excel插件,并在Visual Studio中构建我的项目时开始遇到这个问题。重要的是要告诉你,我以前从来没有遇到过这个问题。什么会导致这种情况发生?
当前回答
如果您更改了程序集版本或复制了错误中声明的托管库的不同版本,则以前编译的文件也可能引用了错误的版本。一个“重建所有”(或删除你的“bin”和“obj”文件夹在前面的评论中提到)应该解决这个问题。
其他回答
您需要使用密钥对程序集进行签名。进入选项卡签名下的项目属性:
我在从包中迁移Excel插件后遇到了这个问题。配置到PackageReference。似乎和这个问题有关。
如果你不使用ClickOnce,下面的工作作为一个粗略的解决方案(它将从.manifest文件中省略所有依赖信息):
Unload project, edit .csproj Find the section looking like this: <!-- Include additional build rules for an Office application add-in. --> <Import Project="$(VSToolsPath)\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets" Condition="'$(VSToolsPath)' != ''" /> Edit a renamed copy of the referenced .targets file (in my case, the file resolved to C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets and I made a copy Microsoft.VisualStudio.Tools.Office_FIX.targets in the same folder - didn't check if it works from a different folder). Find the GenerateApplicationManifest element and change its attribute Dependencies="@(DependenciesForGam)" to Dependencies="". Change the section found in 2. to reference your edited .targets file instead.
每当VS附带的.targets文件版本更新(或者你不会得到更新)时,这将不得不重复,但我希望它能很快得到修复…
尝试update-package -重装-ignoredependencies
请看这个答案。
转到发布页面,点击“应用程序文件”。从那里您应该会看到DLL的列表。确保那些给你带来麻烦的人的发布状态标记为“包括”而不是“先决条件”。
我得到类似的编译器错误。一旦我将dll文件的依赖项目添加到解决方案中,问题就解决了。
推荐文章
- 如何在c#中获得正确的时间戳
- Linq选择列表中存在的对象(A,B,C)
- c# .NET中的App.config是什么?如何使用它?
- c#:如何获得一个字符串的第一个字符?
- String类中的什么方法只返回前N个字符?
- 更好的方法将对象转换为int类型
- 我可以将c#字符串值转换为转义字符串文字吗?
- 在c#中转换char到int
- c#中朋友的对等物是什么?
- 关键字使用virtual+override vs. new
- 在ASP中选择Tag Helper。NET Core MVC
- 如何在没有任何错误或警告的情况下找到构建失败的原因
- 跨线程操作无效:控件“textBox1”从创建它的线程以外的线程访问
- Visual Studio弹出提示:“操作无法完成”
- 否ConcurrentList<T>在。net 4.0?