zoukankan      html  css  js  c++  java
  • 【WCSF】DynamicMethod 的类型所有者无效解决方案

    We came accross this problem in our application and we came up with a solution.

    In our case, the user control had its own presenter which also used interacted with a controller defined in the same module as the presenter. The issue was that when controllers are registered in the module Load method, they are registered only in the module's container - not globally. This means that the controller can only be instantiated if the DI container being used is from the same module.

    To overcome the problem, we simply changed the module initializer's Load method to register the controller on the parent container (same as for global services).

    I.e. change the following code...
    --------------------------------------

    public override void Load(CompositionContainer container)
    {
    base.Load(container);

    AddGlobalServices(container.Parent.Services);
    AddModuleServices(container.Services);

    ...

    container.RegisterTypeMapping<IAdministrationController, AdministrationController>();
    }

    --------------------------------------



    ... into this:
    --------------------------------------

    public override void Load(CompositionContainer container)
    {
    base.Load(container);

    AddGlobalServices(container.Parent.Services);
    AddModuleServices(container.Services);

    ...

    // Register the controller on container.Parent to make it available for DI globally.
    container.Parent.RegisterTypeMapping<IAdministrationController, AdministrationController>();
    }

    --------------------------------------

    刚刚遇到这个问题,解决了留个记号日后待用。

  • 相关阅读:
    hdu 1030 Delta-wave
    POJ 1061 青蛙的约会(拓展欧几里得)
    How Many Zeroes? LightOJ
    HDU
    A
    mysql中函数cast使用
    Django基础08篇 filter&tag
    Django基础07篇 ORM操作
    Django基础06篇 分页
    Django 基础05篇 上下文管理和前端代码复用
  • 原文地址:https://www.cnblogs.com/ahjesus/p/2230855.html
Copyright © 2011-2022 走看看