私は現在、ユニティコンテナとWCFサービスを備えたPRISMアプリケーションを開発中です。モジュールで (WCFプロキシと)次のように私は、WCFクライアントのためのChannelFactoryを登録します。異なるモジュールで解決すると、Unityがタイプを解決できません
InstanceContext instanceContext = new InstanceContext(new TradingPlatformCallback());
unityContainer.RegisterType<DuplexChannelFactory<IGenericTradingInterface>, DuplexChannelFactory<IGenericTradingInterface>>(
new ContainerControlledLifetimeManager(),
new InjectionConstructor(
instanceContext,
"NetNamedPipeBinding_IGenericTradingInterface"));
DuplexChannelFactory<IGenericTradingInterface> factory = unityContainer.Resolve<DuplexChannelFactory<IGenericTradingInterface>>();
factory.Open();
IGenericTradingInterface test = factory.CreateChannel();
test.GetServerInformation();
factory.Close();
を今、すべてが正常に動作しているので、私は別のモジュールでこののChannelFactoryを使用することにしました。
var test = unityContainer.Resolve<DuplexChannelFactory<IGenericTradingInterface>>();
test.Open();
var test2 = test.CreateChannel();
test2.GetServerInformation();
test.Close();
だから、このコードは、行方不明の登録を除き、他のモジュールと全く同じ
です: はここで、モジュールの初期化メソッドです。 これを実行すると、私は次の例外を取得:
Exception is: InvalidOperationException - The type DuplexChannelFactory`1 has mu
ltiple constructors of length 3. Unable to disambiguate.
を解決するとのChannelFactoryのCtorsに問題があるようですが、なぜUnityは最初のモジュールに工場を解決することはできませんこれで?
私が登録して、特定のCTOR呼ばれたと考えられので、私はまた、この例外メッセージを理解していない:任意のアイデア
new InjectionConstructor(
instanceContext,
"NetNamedPipeBinding_IGenericTradingInterface")
?