我试图使用c# 4.0编译我的excel插件,并在Visual Studio中构建我的项目时开始遇到这个问题。重要的是要告诉你,我以前从来没有遇到过这个问题。什么会导致这种情况发生?
当前回答
如果依赖项不匹配,请在解决方案级别的NuGet包管理器中检查Update和consolidated选项卡,协调所有这些。
其他回答
如果您更改了程序集版本或复制了错误中声明的托管库的不同版本,则以前编译的文件也可能引用了错误的版本。一个“重建所有”(或删除你的“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的项目版本,并且错误消失了。
在我的解决方案中有太多的项目需要逐一检查和单独更新,所以我通过以下方法解决了这个问题:
右键单击我的解决方案并选择“管理解决方案的NuGet包…” 进入更新选项卡 找到受影响的包并选择Update 单击OK,这将使包的所有实例保持最新
就我而言,我将项目升级到。net 4.7.2,但仍然使用旧的visual studio版本(2015年)构建。 当我在VS 2019中构建项目时,构建失败消失了。
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.
推荐文章
- 将字符串转换为System.IO.Stream
- 如何从枚举中选择一个随机值?
- 驻留在App_Code中的类不可访问
- 在链式LINQ扩展方法调用中等价于'let'关键字的代码
- dynamic (c# 4)和var之间的区别是什么?
- Visual Studio: ContextSwitchDeadlock
- Visual Studio:如何打破处理异常?
- VS 2017 Git本地提交数据库。每次提交时锁定错误
- 返回文件在ASP。Net Core Web API
- 自定义HttpClient请求头
- 无法启动IIS Express Web服务器,注册URL失败,访问被拒绝
- 如果我使用OWIN Startup.cs类并将所有配置移动到那里,我是否需要一个Global.asax.cs文件?
- VS2013外部构建错误"error MSB4019: The imported project <path> was not found"
- 从另一个列表id中排序一个列表
- 等待一个无效的异步方法