なぜ循環依存関係のエラーが発生しているのかわかりません。私はまた、一見無作為に呼び出された多くの異なるアクティベーションパスとクラスを取得しています。依存関係のないバインディングで循環依存関係の問題が発生する
これは、1年以上働いていたシステムの新しい問題です。それは現時点で変化しており、問題がポップアップした場所を正確に把握するために変更をロールバックしようとする動きが活発になっています。
は、と思われます。これは、マルチスレッドおよび競合状態と関係があります。スレッドをさらに追加すると、エラーが頻繁に表示されます。
Ninjectによって呼び出されたアクティベーションパス/依存関係の1つが私の注意を引いたとき、私はこれを理解するのに苦労していました。 リストされた私の依存関係の1つは、依存関係自体がありませんでした。上記の例で
Ninject.ActivationException: Error activating IMetaValueProvider using binding from IMetaValueProvider to ExecutionOutputMetaValueProvider
A cyclical dependency was detected between the constructors of two services.
Activation path:
6) Injection of dependency IMetaValueProvider into parameter valueProviders of constructor of type MetaValueResolverFactory
5) Injection of dependency IMetaValueResolverFactory into parameter valueResolverFactory of constructor of type MessageExecutionContextFactory
4) Injection of dependency IMessageExecutionContextFactory into parameter executionContextFactory of constructor of type MessageProcessor
3) Injection of dependency IMessageProcessor into parameter messageProcessor of constructor of type MessageProcessingManager
2) Injection of dependency IMessageProcessingManager into parameter messageProcessingManager of constructor of type QueuePollerFactory
1) Request for QueuePollerFactory
、ExecutionOutputMetaValueProvider
は全く依存性を有していません。
- どのように私は循環2つの依存関係が何であるかを正確に伝えることができます。以下は は
ExecutionOutputMetaValueProvider
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DealerVision.Messaging { public class ExecutionOutputMetaValueProvider : IMetaValueProvider { public string MetaKeyPrefix { get { return "Output"; } } public object GetMetaValue(IMessageExecutionContext context, string key) { if(context.ExecutableMessage.Result == null) { throw new Exception($"{nameof(ExecutionOutputMetaValueProvider)} cannot get key \"{key}\" because the {nameof(ExecutableMessageBase)} does not have a result."); } if (context.ExecutableMessage.Result.ExecutionOutput.ContainsKey(key)) { return context.ExecutableMessage.Result.ExecutionOutput[key]; } return null; } public IEnumerable<string> GetPersistantKeys(IMessageExecutionContext executionContext) { if (executionContext.ExecutableMessage.Result == null) return Enumerable.Empty<string>(); List<string> keys = new List<string>(); foreach (var kvp in executionContext.ExecutableMessage.Result.ExecutionOutput) { keys.Add($"{this.MetaKeyPrefix}.{kvp.Key}"); } return keys; } } }
つの質問に、ソースのですか? Ninjectは、そのうちの1つだけに関係する両方の依存関係をリストしません。
- 依存関係が依存関係を持たない場合、どの依存関係も呼び出すことができますか。どのようにサイクルを持つことが可能でしょうか?
明らかに何か不足しています。どんな助けもありがとう。
を導くことができ、問題を示す最小限の検証例を投稿してください。 – Steven
asp.net、asp.net MVCを使用していますか? WCF? – BatteryBackupUnit
@BatteryBackupUnit、いいえ、コンソールアプリです。 –