Owin包版本冲突

时间:2016-07-20 04:39:10

标签: owin nuget-package

  1. 我的解决方案中有两个项目,project1和project2。
  2. Project2倾向于自我托管Owin。
  3. 我使用Microsoft.Owin.Cors包启用了CORS。
  4. 这两个项目都有 Microsoft.OWIN 3.0.1 Microsoft.AspNet.Cors 5.2.3 即可。
  5. 然后,我将project2.exe复制到project1的调试文件夹并调用 来自project1的prorject2.exe。
  6. 然后,当尝试调用project2.exe时,异常框会上升。

  7. 消息是它需要 System.Web.Cors版本5.0.0.0 组装

  8. 当我将 Microsoft.AspNet.Cors 降级为 5.0.0.0 时, 再说它需要 Microsoft.Owin版本2.0.2
  9. 为什么会出现这种情况,如何修复此版本冲突?这两个项目都是在.Net Framewrok 4.5.2下构建的。

1 个答案:

答案 0 :(得分:0)

为了解决冲突,您必须告诉您的代码使用哪个版本的OWIN。这可以通过您的应用程序的app.config来完成。

<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
相关问题