0

我首先创建了一个控制台应用程序并作为自托管 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>

尽管如此,仍然得到同样的例外。任何想法?

谢谢

4

3 回答 3

2

我有这个。复制 app.config 并将其重命名为 web.config。这将使 IIS/IIS Express 能够使用必要的绑定重定向。

于 2014-05-22T22:18:54.337 回答
0

从“引用”列表中,将 Owin DLL 设置为在编译时“始终复制”。

于 2014-05-11T11:07:06.113 回答
0

我认为绑定重定向不会为您做任何事情,因为您引用的版本(2.0.2.0)不在绑定重定向中。

您可以使用程序集绑定日志查看器 (Fuslogvw.exe)工具来调试类型加载异常。

于 2014-05-16T22:43:17.643 回答