我有以下代码:

 public static IEngine CreateEngine()
    {
        UnityContainer container = Unity.LoadUnityContainer(DefaultStrategiesContainerName);
        IEnumerable<IStrategy> strategies = container.ResolveAll<IStrategy>();
        ITraderProvider provider = container.Resolve<ITraderProvider>();

        return new Engine(provider, new List<IStrategy>(strategies));
    }

和配置:
<unity>  <typeAliases>
<typeAlias alias="singleton" type="Microsoft.Practices.Unity.ContainerControlledLifetimeManager, Microsoft.Practices.Unity" />
<typeAlias alias="weakRef" type="Microsoft.Practices.Unity.ExternallyControlledLifetimeManager, Microsoft.Practices.Unity" />
<typeAlias alias="Strategy" type="ADTrader.Core.Contracts.IStrategy, ADTrader.Core" />
<typeAlias alias="Trader" type="ADTrader.Core.Contracts.ITraderProvider, ADTrader.Core" />  </typeAliases>  <containers>
<container name="strategies">
  <types>
    <type type="Strategy" mapTo="ADTrader.Strategies.ThreeTurningStrategy, ADTrader.Strategies" name="1" />
    <type type="Trader" mapTo="ADTrader.MbTradingProvider.MBTradingProvider, ADTrader.MbTradingProvider" />
  </types>
</container>  </containers></unity>

















我收到以下异常:



任何想法?

最佳答案

MbTradingProvider.MBTradingProvider的构造函数调用COM对象(假设名称)上的方法MBTCOMLib.MbtComMgrClass.EnableSplash。此方法中有一个错误,导致写入错误的内存地址。

08-26 00:02