Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Parameterless Constructor Error
Message
 
 
To
All
General information
Forum:
ASP.NET
Category:
MVC
Title:
Parameterless Constructor Error
Environment versions
Environment:
C# 5.0
OS:
Windows 10
Database:
MS SQL Server
Miscellaneous
Thread ID:
01641142
Message ID:
01641142
Views:
51
Hi everybody,

I could not figure out why I am getting this error
<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>
An error occurred when trying to create a controller of type 'MatrixAttributesApiController'. 
Make sure that the controller has a parameterless public constructor.
</ExceptionMessage>
<ExceptionType>System.InvalidOperationException</ExceptionType>
<StackTrace>
at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType) at 

System.Web.Http.Controllers.HttpControllerDescriptor.CreateController(HttpRequestMessage request) at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()
</StackTrace>
<InnerException>
<Message>An error has occurred.</Message>
<ExceptionMessage>
Type 'SysManager.Web.Areas.RetailInventory.Controllers.MatrixAttributesApiController' does not have a default constructor
</ExceptionMessage>
<ExceptionType>System.ArgumentException</ExceptionType>
<StackTrace>
at System.Linq.Expressions.Expression.New(Type type) at System.Web.Http.Internal.TypeActivator.Create[TBase](Type instanceType) at 

System.Web.Http.Dispatcher.DefaultHttpControllerActivator.GetInstanceOrActivator(HttpRequestMessage request, Type controllerType, Func`1& activator) at 

System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)
</StackTrace>
</InnerException>
</Error>
I used our Scaffolding project to generate everything (Controller.cs, APIController.cs and all the front-end as well). I've done the same thing many times including one today very similar.

But I can not figure out why I am getting the error and how to catch it and fix. Normally this error occurs if I forget to add binding in Ninject.config. But I didn't forget that.
I also didn't forget to add mapping to AutoMapper.config although that error would appear later anyway.

So, how exactly can I find out what is wrong this time?

Thanks a lot in advance.
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform