Error - None of the constructors found with 'Orchard.Environment.AutofacUtil.DynamicProxy2.ConstructorFinderWrapper'

試著忘記壹切 提交于 2019-12-09 16:48:18

问题


I have a custom module, Module1. In this module, I am referencing another custom module, Module2. Everything was working fine last week.

I did a fresh re-install of Orchard this morning. Since then, I have been getting this error.

None of the constructors found with 'Orchard.Environment.AutofacUtil.DynamicProxy2.ConstructorFinderWrapper' on type 'Module1' can be invoked with the available services and parameters: Cannot resolve parameter 'Module2' of constructor 'Void .ctor(...)'.

Any idea how to fix this error?

Thanks.


回答1:


That means that an implementation of some interface could not be found. Several thing can have happened: a module may have failed to compile, or you forgot to make an interface derive from IDependency.




回答2:


I know the post is quite old now, but just to link any possible mistake that could cause the described problem... here is my mistake.

I simply forgot to enable the referenced module from the dashboard. Of course that didn't prevent me to add a project reference and module dependency, having the code compiling perfectly .

The point is, my referenced module doesn't contain any content type definition. It is just a module conceived to collect some functionality and common utilities. That's why I forgot to enable it.

Cheers.




回答3:


I had the same issue. It seems that I referenced the concrete class and not the interface in my constructor.

        public OrderService(
            IRepository<Order> orderRepository,
            ProductService productService,
            ProductCategoryService productCategoryService
        )

Instead of

        public OrderService(
            IRepository<Order> orderRepository,
            IProductService productService,
            IProductCategoryService productCategoryService
        )



回答4:


You can get this error if you manually enabled your modules. Make sure you delete App_Data\cache.dat and recycle the app pool.




回答5:


checklist is:

  1. Interface derive from IDependency
  2. Implementation derive from Interface
  3. Constructor references the Interface
  4. Build All and check if all referenced modules compile
  5. Enable module in Admin panel

example:



    public class myController : Controller{
        private readonly IMyService _myService;

        public myController(
            IMyService myService
        ) {
        _myService = myService;
        }
    }



    public interface IMyService : IDependency
    {
        int GetOne();
    }



    public class MyService: IMyService 
    {
        public MyService()
        { // init code }

        public int GetOne()
        { return 1; }
    }



来源:https://stackoverflow.com/questions/10807938/error-none-of-the-constructors-found-with-orchard-environment-autofacutil-dyn

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!