Orchard CMS Quick Tip–No constructors found by AutofacUtil ConstructorFinderWrapper

While writing an Orchard CMS driver class for a tutorial recently I found myself confronted with this error message. If this has happened to you then your gut instinct might be that you are going to have to learn something about Autofac and it might get complicated. Read on for a quick solution.

The exact error message that I was presented with was as follows:

No constructors on type 
can be found with the constructor finder 

My first reaction as I’ve said was that this wasn’t going to be solved until I had started digging into the Autofac documentation.

After taking a second to regroup and realised this was a pretty straightforward issue.


I’d forgotten to make the constructor public. If you don’t specify it then it defaults to private so Autofac couldn’t find it.

So if, for example, your code looks something like this:

FeaturedProductDriver(IFeaturedProductService featuredProductService) {
  _featuredProductService = featuredProductService;

Then you just need to add a simple public modifier to the start:

public FeaturedProductDriver(IFeaturedProductService featuredProductService) {
  _featuredProductService = featuredProductService;

And Autofac will be happy.

No comments :