我一直试图没有成功获得ASP Web API/Autofac集成工作。我创建了一个简单的项目,其中一个Controller返回一个字符串,并且能够成功运行应用程序。然而,当我融入到Autofac解决方案,在运行时我收到System.EntryPointNotFoundException: Entry point was not found.
ASP Web API和Autofac集成异常
- 的Visual Studio Pro的2013
- .NET 4.5
这里是包含在项目库中的版本,当我创建它在我的机器上(不包括Autofac库)。我从Nuget获得Autofac库,所有其他库都在本地安装。
- 的System.Web 4.0
- System.Web.Extensions程序4.0
- System.Web.Http 5.0
- System.Web.Http.WebHost 5.0
- System.Web.Services 4.0
- Autofac 3.0 /说明说3.1.5
- Autofac.Integration.WebApi 3.0 /描述说3.1
我把Autofac代码在我的注册方法是这样的:
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
//Other code left out for brevity
var builder = new ContainerBuilder();
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
// Set the dependency resolver to be Autofac.
var container = builder.Build();
config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
}
}
我收到EntryPointNotFoundException
在Application_Start方法:
public class WebApiApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
GlobalConfiguration.Configure(WebApiConfig.Register);
}
}
于是我通过的NuGet和升级ALL包得到这些版本:
- System.Web 4.0 个
- System.Web.Extensions程序4.0
- System.Web.Http 5.2.2
- System.Web.Http.WebHost 5.2.2
- System.Web.Services 4.0
- Autofac 3.5 /描述说:3.5 0.2
- Autofac.Integration.WebApi 3.0 /描述说3.1.0
这个片段就是现在插入到web.config文件:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.0" newVersion="3.5.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
当我再次运行应用程序,我仍然收到System.EntryPointNotFoundException: Entry point was not found.
缺少什么我在这里得到Autofac和Web API很好地一起玩?
谢谢,凯尔
你如何举办的applcation?在IIS中还是使用IIS Express?你可以在新创建的项目中重现这个错误吗?我只能找到一个有点相关的文章:http://www.aaron-powell.com/posts/2010-04-08-problems-with-assembly-trust.html – nemesv 2014-10-26 16:50:11