UnityからWCFプロジェクトにインターセプタを設定しています。サービスからメソッドを呼び出すと、System.StackOverflowException
が返されます。これは私が設定したインターセプタから来ますが、私はそれを解決する方法がわかりません。 FYIWCFのUnityインターセプタでSystem.StackOverflowExceptionを取得する
:私はcircular dependancyまたはa non-terminating recursion
を持っていた場合、私はここでは、Webサービス
のコード工場だ私はユニティV4とUnity.WCF v3.0の
を使用しています確認してください
public class WcfServiceFactory : UnityServiceHostFactory
{
protected override void ConfigureContainer(IUnityContainer container)
{
// register all your components with the container here
List<string> lstNomAssemblyToLoad = new List<string>();
List<Assembly> lstAssemblyToLoad;
lstNomAssemblyToLoad.Add("Service");
lstNomAssemblyToLoad.Add("Interfaces");
lstNomAssemblyToLoad.Add("Bll");
lstNomAssemblyToLoad.Add("Dal");
// Loading specific interface from unity.config
container = container.LoadConfiguration();
// Resolving interfaces without explicit declaration
lstAssemblyToLoad = AppDomain.CurrentDomain.GetAssemblies().Where(a => lstNomAssemblyToLoad.Contains(a.GetName().Name)).ToList();
container.AddNewExtension<Interception>();
container.RegisterTypes(AllClasses.FromAssemblies(lstAssemblyToLoad),
WithMappings.FromAllInterfaces,
WithName.Default,
WithLifetime.ContainerControlled,
getInjectionMembers: c => new InjectionMember[]
{
new Interceptor<VirtualMethodInterceptor>(),
new InterceptionBehavior<ExceptionInterceptionBehavior>()
},
overwriteExistingMappings: true);
}
}
マイInterceptionBehavior
public class ExceptionInterceptionBehavior : IInterceptionBehavior
{
public IEnumerable<Type> GetRequiredInterfaces()
{
return Type.EmptyTypes;
}
public bool WillExecute
{
get { return true; }
}
public IMethodReturn Invoke(IMethodInvocation input, GetNextInterceptionBehaviorDelegate getNext)
{
var result = getNext()(input, getNext);
return result;
}
}
私のウェブサービスのメソッドを呼び出すたびにAn unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll
が得られる理由は何ですか?
トレース
あなたはより多くの情報が必要な場合はお気軽にお問い合わせください。
UPDATE私はインターセプタを削除する場合は、もちろん私が持っていない
例外はもう助けを
感謝:
container.RegisterTypes(AllClasses.FromAssemblies(lstAssemblyToLoad),
WithMappings.FromAllInterfaces,
WithName.Default,
WithLifetime.ContainerControlled,
null,
overwriteExistingMappings: true);
しかし、私はちょうどWithName.Default
に変更した場合WithName.TypeName
とインターセプタを保つ、私は例外を取得しない...私は理由を理解していない...
container.RegisterTypes(AllClasses.FromAssemblies(lstAssemblyToLoad),
WithMappings.FromAllInterfaces,
WithName.TypeName,
WithLifetime.ContainerControlled,
getInjectionMembers: c => new InjectionMember[]
{
new Interceptor<VirtualMethodInterceptor>(),
new InterceptionBehavior<ExceptionInterceptionBehavior>()
},
overwriteExistingMappings: true);
例外スタックトレースを共有できますか? – Dhawalk
私が得たもののスクリーンショットで答えを更新しました –
これは完全なスタックではないと思います。さらに下にスクロールすると、コードから始まるものがありますか? – Dhawalk