ASP.NET MVC 'No Parameterless Constructor' can be a misleading error
Problem
We've all seen it:
And we usually waste time trying to figure out why your IoC container isn't working right, etc.
The error is not about an misconfigured IoC. It's because something -during- the dependency injection, failed.
The real error is actually hiding deep down in the stack trace, where the error message is not being displayed.
Solution
IoC hasn't been configured correctly. Check what the controller is trying to inject.
- Check if you're requiring a database or 3rd party service.
- Check if you can access the database or 3rd party service.
For myself, I usually have a dependency on a Raven Database. As such, I sometimes forget to start it, when doing local development. So when an IDocumentSession
is being injected, it requires an IDocumentStore
which fails to instantiate because there is no RavenDb running. Fix: run RavenDb :)
Written by Pure Krome
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#.net
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#