移动到网页API RC,获取:未找到方法:'System.Web.Http.Services.DependencyResolver System.Web.Http.HttpConfiguration.get_ServiceResolver() [英] Move to Web API RC, Get: Method not found: 'System.Web.Http.Services.DependencyResolver System.Web.Http.HttpConfiguration.get_ServiceResolver()'

查看:719
本文介绍了移动到网页API RC,获取:未找到方法:'System.Web.Http.Services.DependencyResolver System.Web.Http.HttpConfiguration.get_ServiceResolver()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搬离的WebAPI测试到的WebAPI RC一个网站,并在加载该网站我现在得到一个错误:未找到方法:'System.Web.Http.Services.DependencyResolver System.Web.Http .HttpConfiguration.get_ServiceResolver()'。

I moved a site from WebAPI Beta to WebAPI RC, and am now getting an error upon loading the site: Method not found: 'System.Web.Http.Services.DependencyResolver System.Web.Http.HttpConfiguration.get_ServiceResolver()'.

出现的错误,我尝试注册我的 AutoFacWebApiDependencyResolver (每指令的这里):

The error occurs the first time that I am trying to register my AutoFacWebApiDependencyResolver (per instructions here):

var resolver = new AutofacWebApiDependencyResolver(IoCManager.Container);
GlobalConfiguration.Configuration.DependencyResolver = resolver;

堆栈跟踪显示以下内容:

The stacktrace shows the following:

[MissingMethodException: Method not found: 'System.Web.Http.Services.DependencyResolver System.Web.Http.HttpConfiguration.get_ServiceResolver()'.]
   System.Web.Http.GlobalConfiguration.<.cctor>b__0() +0
   System.Lazy`1.CreateValue() +12775823
   System.Lazy`1.LazyInitValue() +355
   StatusBoard.Web.MvcApplication.RegisterDependencyInjection() in C:\path-tp-app\Global.asax.cs:125
   StatusBoard.Web.MvcApplication.Application_Start() in C:\path-to-app\Global.asax.cs:75

根据这一点,它显示该错误静态GlobalConfiguration类的初始化期间发生。当我深入到源为该类别,我看到以下内容:

Based on this, it appears that the error is occurring during initialization of the static GlobalConfiguration class. When I drill down into the source for that class, I see the following:

private static Lazy<HttpConfiguration> _configuration = new Lazy<HttpConfiguration>((Func<HttpConfiguration>) (() =>
{
  local_0 = new HttpConfiguration((HttpRouteCollection) new HostedHttpRouteCollection(RouteTable.Routes));
  local_0.get_ServiceResolver().SetService(typeof (IBuildManager), (object) new WebHostBuildManager());
  return local_0;
}));
private static Lazy<HttpControllerDispatcher> _dispatcher = new Lazy<HttpControllerDispatcher>((Func<HttpControllerDispatcher>) (() => new HttpControllerDispatcher(GlobalConfiguration._configuration.Value)));

public static HttpConfiguration Configuration
{
  get
  {
    return GlobalConfiguration._configuration.Value;
  }
}

第四条线在这里似乎是问题 - 它正试图调用,在 HttpConfiguration 类不再存在get_ServiceResolver()方法(应该是 DependncyResolver 来代替,可能)。

The fourth line here seems to be the issue - it is trying to call a get_ServiceResolver() method that no longer exists in the HttpConfiguration class (should be DependncyResolver instead, probably).

这仅仅是一个与RC为错误的WebAPI?是否有某种方式,我可以解决这个问题?还是我停留在一些DLL /地狱的NuGet(如果有的话,我怎么能自拔自己)?

Is this just a bug with the RC for WebAPI? Is there some way that I can get around this? Or am I stuck in some DLL/Nuget hell (and if so, how can I extricate myself)?

推荐答案

一定要包括正确的NuGet包(RC!)并在你建立你的包在计算机上安装新的mvc4rc。

be sure to include the correct nuget package (RC!) and install the new mvc4rc on the machine where you build your package.

这篇关于移动到网页API RC,获取:未找到方法:'System.Web.Http.Services.DependencyResolver System.Web.Http.HttpConfiguration.get_ServiceResolver()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆