2013-02-07 84 views
8

我有一個MVC4應用程序之前, 我已經更新Autofac的版本,每件事情都很好,現在我有這個奇怪的例外。奇怪的異常後更新Autofac

請幫忙!?

Method not found: 'Autofac.Builder.IRegistrationBuilder`3<!0,!1,!2> Autofac.Builder.IRegistrationBuilder`3.InstancePerMatchingLifetimeScope(System.Object)'. 



Line 22:    var builder = new ContainerBuilder(); 
Line 23:    builder.RegisterFilterProvider(); 
Line 24:    builder.Register(x => new AuthorizationService()).As<IAuthService>().InstancePerHttpRequest(); 
Line 25:    builder.Register(x => new HeaderRepository()).As<IUIHeaderRepository>().InstancePerHttpRequest(); 
Line 26:    builder.Register(x => new PageBuilder()).As<IUPageBuilder>().InstancePerHttpRequest(); 

堆棧跟蹤:

[MissingMethodException: Method not found: 'Autofac.Builder.IRegistrationBuilder`3<!0,!1,!2> Autofac.Builder.IRegistrationBuilder`3.InstancePerMatchingLifetimeScope(System.Object)'.] 
     Autofac.Integration.Mvc.RegistrationExtensions.InstancePerHttpRequest(IRegistrationBuilder`3 registration) +0 
     Application.UI.Web.Services.HttpDependencyInjectionResolver.RegisterDependencies() in c:\Users\user\Documents\Visual Studio 11\Projects\MyProject\Application.UI.Web\Services\HttpDependencyInjectionResolver.cs:24 
     Application.UI.Web.MvcApplication.Application_Start() in c:\Users\user\Documents\Visual Studio 11\Projects\MyProject\Application.UI.Web\Global.asax.cs:42 

    [HttpException (0x80004005): Method not found: 'Autofac.Builder.IRegistrationBuilder`3<!0,!1,!2> Autofac.Builder.IRegistrationBuilder`3.InstancePerMatchingLifetimeScope(System.Object)'.] 
     System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9859441 
     System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118 
     System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172 
     System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336 
     System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296 

    [HttpException (0x80004005): Method not found: 'Autofac.Builder.IRegistrationBuilder`3<!0,!1,!2> Autofac.Builder.IRegistrationBuilder`3.InstancePerMatchingLifetimeScope(System.Object)'.] 
     System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9873784 
     System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101 
     System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254 

回答

14

您還需要更新Autofac.Integration.Mvc到相應的版本。

如果這沒有幫助,請確保這兩個文件的新版本實際上都在執行代碼的文件夾中。也許其中之一不能被複制到IIS文件夾?

+0

謝謝,但它沒有幫助我...仍然有相同的錯誤 – IamStalker

+0

你使用NuGet來管理你的參考或手動嗎? –

+0

我正在使用NUget – IamStalker

1

這很可能是您正在使用asp.net MVC 3具有與方法InstancePerHttpRequest()

被發現autofac MVC 3的contrib(忘了包的名稱)不兼容。 在我的情況升級到mvc 4修復了這個問題。