現在、次のような例外が発生していますが、発生するタイミングを特定できませんでした。私の賭けはおそらくそれがUnityの依存性注入コンテナとタイプの登録方法に関係しているということです。ここではエラーがあります:Unityと統合されたSignalRのPerRequestLifetimeManagerに関連する例外
The PerRequestLifetimeManager can only be used in the context of an HTTP request. Possible causes for this error are using the lifetime manager on a non-ASP.NET application, or using it in a thread that is not associated with the appropriate synchronization context.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The PerRequestLifetimeManager can only be used in the context of an HTTP request. Possible causes for this error are using the lifetime manager on a non-ASP.NET application, or using it in a thread that is not associated with the appropriate synchronization context.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: The PerRequestLifetimeManager can only be used in the context of an HTTP request. Possible causes for this error are using the lifetime manager on a non-ASP.NET application, or using it in a thread that is not associated with the appropriate synchronization context.]
Microsoft.Practices.Unity.Mvc.UnityPerRequestHttpModule.GetDictionary(HttpContext context) +195
Microsoft.Practices.Unity.Mvc.UnityPerRequestHttpModule.GetValue(Object lifetimeManagerKey) +50
Microsoft.Practices.ObjectBuilder2.LifetimeStrategy.PreBuildUp(IBuilderContext context) +146
Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) +396
Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp(NamedTypeBuildKey newBuildKey) +130
lambda_method(Closure , IBuilderContext) +206
Microsoft.Practices.ObjectBuilder2.<>c__DisplayClass1.<GetBuildMethod>b__0(IBuilderContext context) +33
Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context) +337
Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) +396
Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp(NamedTypeBuildKey newBuildKey) +130
lambda_method(Closure , IBuilderContext) +206
Microsoft.Practices.ObjectBuilder2.<>c__DisplayClass1.<GetBuildMethod>b__0(IBuilderContext context) +33
Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context) +337
Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) +396
Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp(NamedTypeBuildKey newBuildKey) +130
lambda_method(Closure , IBuilderContext) +212
Microsoft.Practices.ObjectBuilder2.<>c__DisplayClass1.<GetBuildMethod>b__0(IBuilderContext context) +33
Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context) +337
Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) +396
Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides) +238
[ResolutionFailedException: Resolution of the dependency failed, type = "TradeForce.Portal.Hubs.ExecutionReportsHub", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The PerRequestLifetimeManager can only be used in the context of an HTTP request. Possible causes for this error are using the lifetime manager on a non-ASP.NET application, or using it in a thread that is not associated with the appropriate synchronization context.
-----------------------------------------------
At the time of the exception, the container was:
Resolving TradeForce.Portal.Hubs.ExecutionReportsHub,(none)
Resolving parameter "iExecutionReportsBusiness" of constructor TradeForce.Portal.Hubs.ExecutionReportsHub(TradeForce.Dominio.Interfaces.Business.Reports.IExecutionReportsBusiness iExecutionReportsBusiness, TradeForce.Dominio.Interfaces.Repository.NH.IUsers iUsers, TradeForce.Dominio.Interfaces.Repository.NH.ICollaborators iCollaborators, TradeForce.Infraestrutura.Persistencia.NHibernateUtil.SessionProvider sessionProvider)
Resolving TradeForce.Business.Entities.Reports.ExecutionReportsBusiness,(none) (mapped from TradeForce.Dominio.Interfaces.Business.Reports.IExecutionReportsBusiness, (none))
Resolving parameter "iExecutionReports" of constructor TradeForce.Business.Entities.Reports.ExecutionReportsBusiness(TradeForce.Dominio.Interfaces.Repository.NH.Reports.IExecutionReports iExecutionReports)
Resolving TradeForce.Infraestrutura.DAO.NH.Reports.DAOExecutionReports,(none) (mapped from TradeForce.Dominio.Interfaces.Repository.NH.Reports.IExecutionReports, (none))
Resolving parameter "sessionProvider" of constructor TradeForce.Infraestrutura.DAO.NH.Reports.DAOExecutionReports(TradeForce.Infraestrutura.Persistencia.NHibernateUtil.SessionProvider sessionProvider)
Resolving TradeForce.Infraestrutura.Persistencia.NHibernateUtil.SessionProvider,(none)
]
Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides) +500
Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides) +20
TradeForce.Portal.Helpers.UnityHubActivator.Create(HubDescriptor descriptor) +108
Microsoft.AspNet.SignalR.Hubs.HubDispatcher.CreateHub(IRequest request, HubDescriptor descriptor, String connectionId, StateChangeTracker tracker, Boolean throwIfFailedToCreate) +601
Microsoft.AspNet.SignalR.Hubs.HubDispatcher.OnReceived(IRequest request, String connectionId, String data) +614
Microsoft.AspNet.SignalR.<>c__DisplayClassc.<ProcessRequestPostGroupRead>b__7() +41
Microsoft.AspNet.SignalR.TaskAsyncHelper.FromMethod(Func`1 func) +25
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +181
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +69
Microsoft.AspNet.SignalR.Transports.<ProcessSendRequest>d__12.MoveNext() +944
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +181
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +69
Microsoft.Owin.Mapping.<Invoke>d__0.MoveNext() +599
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +181
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +69
Microsoft.Owin.Mapping.<Invoke>d__0.MoveNext() +870
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +181
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +69
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.<RunApp>d__5.MoveNext() +203
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +181
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +69
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.<DoFinalWork>d__2.MoveNext() +193
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResult ar) +96
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +509
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +146
はここでユニティを利用しているSignalRのハブです:
public class ExecutionReportsHub : BaseHub
{
private readonly IExecutionReportsBusiness _iExecutionReportsBusiness;
private readonly IUsers _iUsers;
private readonly ICollaborators _iCollaborators;
private readonly SessionProvider _sessionProvider;
public ExecutionReportsHub(IExecutionReportsBusiness iExecutionReportsBusiness, IUsers iUsers, ICollaborators iCollaborators, SessionProvider sessionProvider)
{
_iExecutionReportsBusiness = iExecutionReportsBusiness;
_iUsers = iUsers;
_iCollaborators = iCollaborators;
_sessionProvider = sessionProvider;
}
// More code...
}
タイプ登録:
public class UnityConfig
{
public static void RegisterTypes(IUnityContainer container)
{
container.RegisterInstance(new SessionFactoryProvider());
container.RegisterType<SessionProvider>(new PerRequestLifetimeManager());
container.RegisterType<IUsers, DAOUsers>();
container.RegisterType<ICollaborators, DAOCollaborators>();
container.RegisterType<IExecutionReportsBusiness, ExecutionReportsBusiness>();
container.RegisterType<IHubActivator, UnityHubActivator>(new PerRequestLifetimeManager());
container.RegisterType<ExecutionReportsHub, ExecutionReportsHub>(new ContainerControlledLifetimeManager());
// Other unrelated types being registered...
}
}
エラーは以下のいずれかの実行中に発生していますハブ・メソッドはクライアント側コールから取得します。
ありがとうございます。
:
そして、あなたの登録。 [SignalR内部であるため、要求ごとのライフタイム依存性についてはSignalRにはサポートがありません。](http://docs.autofac.org/en/latest/integration/signalr.html) –
ありがとう@ErkanDemirel私は見ていきますそれがうまくいくかどうかをここに報告してください。 – Zignd