Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

i got error "Value cannot be null.\r\nParameter name: serviceType"

Tags:

nopcommerce

I was following a tutorial , but after setting the project build path, I run the project and navigate to plugins. Then I got the following error. An exception of type 'System.ArgumentNullException' occurred in Autofac.dll but was not handled in user code,

"Value cannot be null.\r\nParameter name: serviceType"

and i don't know that which method i should add and in which class?

Please help!

like image 451
Ajisha Avatar asked Apr 30 '26 00:04

Ajisha


1 Answers

you must register the service you created in the plugin and also the repository for your entity in DependencyRegistrar.cs file so that run time Autofac can found them for example:

public class DependencyRegistrar : IDependencyRegistrar
{
    public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
    {
        //data context
        this.RegisterPluginDataContext<MYPLUGINObjectContext>(builder, "nop_object_context_misc_MYPLUGIN");

        //override required repository with our custom context
        builder.RegisterType<EfRepository<ENTITY>>()
            .As<IRepository<ENTITY>>()
            .WithParameter(ResolvedParameter.ForNamed<IDbContext>("nop_object_context_misc_MYPLUGIN"))
            .InstancePerHttpRequest();
    }

    public int Order
    {
        get { return 0; }
    }
}
like image 130
Sherif Ahmed Avatar answered May 05 '26 16:05

Sherif Ahmed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!