2

更新Autofac.Mvc5从3.3.2更新到3.3.3时发生错误 我将问题发布到github https://github.com/autofac/Autofac/issues/572#issuecomment-63236738,并得到了我需要询问的回复在这里:)更新Autofac.Mvc5从3.3.2更新到3.3.3时出错

下面我的情况:

我有什么:

// Setup DI as default MVC controller factory 
DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); 

我需要这在定义成员资格提供的注入属性使用

protected IMembershipService MembershipService 
{ 
    get 
    { 
     return DependencyResolver.Current.GetService(); 
    } 
} 

问题:依赖解析器的类型是不是“Autofac.Integration.Mvc.AutofacDependencyResolver”

请帮我解决这个问题。

UPDATE 所以现在我有这样的错误更新后从3.3.2

的依赖解析器的类型是“Autofac.Integration.Mvc.AutofacDependencyResolver”的不和似乎并没有被包裹使用Castle Project中的DynamicProxy。此问题可能是DynamicProxy实现发生更改或使用其他代理库来包装依赖关系解析程序的结果。

任何想法如何解决?

URL图像错误http://i.stack.imgur.com/yJJXX.png

UPDATE 这里我发现了什么 github.com/autofac/Autofac/blob/82cc138596e74095f50720319feb2a2ce734310d/Core/Source/Autofac.Integration.Mvc/AutofacDependencyResolver.cs 这个我们有文件的部分,例外抛出这样的文本。 这只是所有源代码中的一部分,所以我认为我需要继续前进,并找出为什么我会遇到这个问题。此外,何时以及为什么我的代码请求此方法AutofacDependencyResolver.Current。 当我检查我没有直接调用AutofacDependencyResolver.Current。 我需要调查其他变体(地点)的调用。

+0

但是你的问题是什么? – Steven 2014-11-20 22:00:49

+0

错误是什么? – 2014-11-21 04:06:42

+0

我的问题:依赖关系解析器不是类型'Autofac.Integration.Mvc.AutofacDependencyResolver' – 2014-11-24 20:24:37

回答

0

现在我看到这样的分辨率

 // Create DI container 
     var builder = new ContainerBuilder(); 

     // Register application modules 
     Autofac_RegisterApplicationModules(builder); 

     // Register filter provider 
     //builder.RegisterFilterProvider(); 

     // Register MVC specific abstractions (HttpRequestBase,HttpResponceBase etc) 
     builder.RegisterModule(new AutofacWebTypesModule()); 

     // container 
     var container = builder.Build(); 

正如你可以看到我的评论此行

//builder.RegisterFilterProvider(); 

但我需要确认,如果这是OK!

请问,谁知道解释它是否正确和/或如何成为。

跟踪结果BELOW - 需要帮助

[InvalidOperationException: The dependency resolver is not of type 'Autofac.Integration.Mvc.AutofacDependencyResolver' and does not appear to be wrapped using DynamicProxy from the Castle Project. This issue could be the result of a change in the DynamicProxy implementation or the use of a different proxy library to wrap the dependency resolver.] 
    Autofac.Integration.Mvc.AutofacDependencyResolver.get_Current() +367 
    Autofac.Integration.Mvc.AutofacFilterProvider.GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +196 
    System.Web.Mvc.FilterProviderCollection.GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +279 
    System.Web.Mvc.ControllerActionInvoker.GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +62 
    System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state) +436 
    System.Web.Mvc.Controller.<BeginExecuteCore>b__1c(AsyncCallback asyncCallback, Object asyncState, ExecuteCoreState innerState) +82 
    System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +73 
    System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +151 
    System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object callbackState, BeginInvokeDelegate`1 beginDelegate, EndInvokeVoidDelegate`1 endDelegate, TState invokeState, Object tag, Int32 timeout, SynchronizationContext callbackSyncContext) +105 
    System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +588 
    System.Web.Mvc.Controller.<BeginExecute>b__14(AsyncCallback asyncCallback, Object callbackState, Controller controller) +47 
    System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +65 
    System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +151 
    System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object callbackState, BeginInvokeDelegate`1 beginDelegate, EndInvokeVoidDelegate`1 endDelegate, TState invokeState, Object tag, Int32 timeout, SynchronizationContext callbackSyncContext) +139 
    System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +484 
    System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +50 
    System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__4(AsyncCallback asyncCallback, Object asyncState, ProcessRequestState innerState) +98 
    System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +73 
    System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +151 
    System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object callbackState, BeginInvokeDelegate`1 beginDelegate, EndInvokeVoidDelegate`1 endDelegate, TState invokeState, Object tag, Int32 timeout, SynchronizationContext callbackSyncContext) +106 
    System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +446 
    System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +88 
    System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +50 
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +301 
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155 

后,我的新的调查,我发现了这个问题。 我的网站使用MVCSiteMap

http://i.stack.imgur.com/7xnul.png

我现在检查如何配置MvcSiteMapProvider不改变DI。

<add key="MvcSiteMapProvider_UseExternalDIContainer" value="false" /> 

所以我认为我需要将它更改为true来解决问题。 我现在正在进行中,并且很快就会通知您。

如果您有解决方案,随时更新我的​​观点!

+0

我也遇到了这个问题,但我不明白这个问题。如果我们停止注册过滤器提供程序,那么会不会导致依赖于这些提供程序的代码出现问题? – ChaseMedallion 2015-04-07 20:38:35

+0

我在下面添加新的答案,请检查它。 – 2015-04-21 16:25:51

0

我没有工作对我来说这行:

Autofac_RegisterApplicationModules(builder); 

,所以我改变了它本:

RegisterAssemblyModules(builder); 

和现在的工作。

感谢您的解决方案!

+0

Autofac_RegisterApplicationModules(builder);只是我注册autofac模块和RegisterAssemblyModules(构建器)的方法;在那里。我认为你的问题是因为你没有请求RegisterAssemblyModules(builder);.所以这与我的问题无关。 – 2014-12-18 15:41:51