【问题标题】:i got error "Value cannot be null.\r\nParameter name: serviceType"我收到错误“值不能为空。\r\n参数名称:serviceType”
【发布时间】:2014-04-23 11:19:06
【问题描述】:

我正在学习教程,但在设置项目构建路径后,我运行项目并导航到插件。然后我收到以下错误。 Autofac.dll 中出现“System.ArgumentNullException”类型的异常,但未在用户代码中处理,

“值不能为空。\r\n参数名称:serviceType”

我不知道我应该添加哪个方法以及在哪个类中?

请帮忙!

【问题讨论】:

  • 您正在开发哪种类型的插件?

标签: nopcommerce


【解决方案1】:

您必须在 DependencyRegistrar.cs 文件中注册您在插件中创建的服务以及实体的存储库,以便运行时 Autofac 可以找到它们,例如:

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; }
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-23
    • 2021-08-29
    • 1970-01-01
    • 2012-02-22
    • 1970-01-01
    • 1970-01-01
    • 2021-05-04
    • 1970-01-01
    相关资源
    最近更新 更多