2011-09-15 158 views
1

我试图将本地完美运行的ASP.NET MVC3应用程序上载到Windows Azure。Windows Azure,MVC3,为此对象定义的无参数构造函数

当我将应用程序上传到azure时,它显示为“就绪”。但是,如果我打电话给它,会出现以下错误:

No parameterless constructor defined for this object. 

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.MissingMethodException: No parameterless constructor defined for this object. 

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace: 


[MissingMethodException: No parameterless constructor defined for this object.] 
    System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0 
    System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) +117 
    System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +247 
    System.Activator.CreateInstance(Type type, Boolean nonPublic) +106 
    System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +84 

[InvalidOperationException: An error occurred when trying to create a controller of type 'DummyAnwendung.Controllers.AccountController'. Make sure that the controller has a parameterless public constructor.] 
    System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +247 
    System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +85 
    System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +280 
    System.Web.Mvc.<>c__DisplayClass6.<BeginProcessRequest>b__2() +66 
    System.Web.Mvc.<>c__DisplayClassb`1.<ProcessInApplicationTrust>b__a() +19 
    System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Func`1 func) +161 
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +389 
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +371 

有人有一个想法,错误可能导致什么? 我使用DI统一应用程序块..

问候 帕特

回答

0

该错误消息指出以下几点:

'DummyAnwendung.Controllers.AccountController'. Make sure that the controller has a parameterless public constructor 

如果不定义构造函数的一类,一无参数构造函数将被创建。但是,如果使用参数定义构造函数,则不会创建无参数构造函数。

定义该类的parameterlass构造函数。

+0

这样做了。只需设置一个无参数的构造函数:-) – pat

相关问题