我正在做一个ASP。使用实体框架Core 1.0.1的。NET 4.6.2应用程序。应用程序在本地构建和运行良好,然而,TFS 2015 Update 3在构建和部署时处于中断状态。至少有一个(我现在知道的)必需的程序集被旧版本覆盖了。
System.Collections。不可变的1.2.0。是EF所要求的。然而,在1.2.0被复制到bin文件夹后的构建日志中,我可以看到另一个版本(1.1.37.0)被复制到bin。它是从Microsoft.Net.Compilers.1.3.2包中复制的,并覆盖新版本。
当应用程序运行时,它期望看到1.2.0,而不是1.1.37。然后抛出以下错误:
Could not load file or assembly 'System.Collections.Immutable,
Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
or one of its dependencies. The located assembly's manifest
definition does not match the assembly reference.
(Exception from HRESULT: 0x80131040)
有办法防止这种情况吗?
根据这个网站,这是一个已知的问题,这个问题应该在Microsoft.CodeDom.Providers.DotNetCompilerPlatform 1.0.2中可用。
http://www.nuget.org/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform/如果修复不起作用,你可以通过更新Microsoft.CodeDom.Providers.DotNetCompilerPlatform包来解决这个问题,binding-redirect解决方案是目前最简单的解决方案。
<dependentAssembly>
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.2.0.0" newVersion="1.1.36.0" />
</dependentAssembly>
其他有用链接:
- https://github.com/aspnet/EntityFramework/issues/6220
- https://github.com/NuGet/Home/issues/3274