2009-12-12 53 views
0

我使用的是安裝了VS2010 Beta 2中,我掛鉤WindsorControllerFactory像這樣ASP.NET MVC預覽2:asp.net的MVC不使用控制器工廠指定

Container = new WindsorContainer(); 
Container.RegisterControllers(typeof(HomeController).Assembly); 
ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(Container)); 

我的HomeController有一個

此對象定義無參數的構造函數:運行我收到以下錯誤,當傳遞到構造函數,依賴。

[MissingMethodException: No parameterless constructor defined for 

this object.] System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0 System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) +86 System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) +230 System.Activator.CreateInstance(Type type, Boolean nonPublic) +67 System.Activator.CreateInstance(Type type) +6 System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +522

[InvalidOperationException: An error occurred when trying to create a 

controller of type 'Xenotar.WedPlannerPro.Controllers.HomeController'. Make sure that the controller has a parameterless public constructor.] System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +659 System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +198 System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) +225 System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext) +86 System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext) +36 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

通過觀察該堆棧跟蹤它看起來並不像MVC是使用WindsorControllerFactory而是仍然使用原有的DefaultControllerFactory?

當在MVC 1.0中這樣做時,它就可以工作。

SOLUTION

的MvcContrib不與ASP.NET MVC兼容2.

回答

0

你應該能夠修改MvcContrib與ASP.NET MVC的工作2.控制器註冊的代碼相當最小的。