问题
I am trying to inject IWorkContext
in WebStoreContext
or StoreService
.
but when we run the project it give's errors.
Error on ContainerManager.cs(line no 113)
An unhandled exception of type 'System.StackOverflowException' occurred in Autofac.dll
example
private readonly IWorkContext _workContext = EngineContext.Current.Resolve<IWorkContext>();
Or
private readonly IWorkContext _workContext;
public ctor(IWorkContext workContex)
{
this._workContex = workContext;
}
回答1:
Circular references are not allowed. WorkContext already depends on IStoreContext. You cannot make StoreContext already depends on IWorkContext.
来源:https://stackoverflow.com/questions/24566962/when-we-inject-iworkcontext-in-webstorecontext-its-gives-error