【发布时间】:2015-05-06 17:55:20
【问题描述】:
我有一个使用 Microsoft.AspNet.WebApi.OwinSelfHost 的简单项目。这是一个 Owin 自托管的 WebApi 2 项目。该项目非常类似于:-
https://github.com/attilah/AngularJSAuthentication
我唯一的区别是我的安全模块是在单独的程序集中(一切都类似于上面的项目)。我使用 Autofac 来解决我的依赖关系。
这个项目在没有 Autofac 的情况下工作。但是,一旦我尝试使用相应的安全模块和 Autofac 设置我的项目,我所面临的就是这个错误:-
Could not load file or assembly 'System.Web.Http, Version=5.2.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)
我的配置非常受此线程的启发:-
Dependency injection not working with Owin self-hosted Web Api 2 and Autofac
此外,我发现其他人正在为 Autofac 的这个依赖错误而苦苦挣扎,并且能够通过重新安装 Microsoft.AspNet.WebApi.WebHost 来解决类似的问题:
GlobalConfiguration.Configure() not present after Web API 2 and .NET 4.5.1 migration
但这对我不起作用,我不知道为什么。我尝试从头开始重新安装所有内容也无济于事。除了 Autofac 在重新安装时还有一些权限问题之外。
有人遇到过这个错误吗?请帮忙。谢谢!
【问题讨论】:
标签: .net asp.net-web-api autofac owin self-hosting