我首先创建了一个控制台应用程序并作为自托管 OWIN 应用程序运行。已安装 Web API,一切正常。
现在我安装了 SystemWeb nuget 包,将应用程序类型更改为“类库”,仅将输出文件夹更改为“bin\”。
当我使用 IIS Express 运行应用程序时,第一次加载应用程序时,我收到一个异常:
Could not load file or assembly 'Microsoft.Owin, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
我意识到 System.Web.Http.Owin 引用的是 Microsoft.Owin -V 2.0.2.0。
在 App.config 中存在以下内容:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
</dependentAssembly>
</assemblyBinding>
尽管如此,仍然得到同样的例外。任何想法?
谢谢