I have been struggling to get NopCommerce to pick up a registered interface.
This line here
this._connectionService = EngineContext.Current.Resolve<IConnectionService>();
is causing the error
Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it has already been disposed.
I have registered the interface in the DependencyRegistrar
builder.RegisterType<ConnectionService>().As<IConnectionService>().InstancePerLifetimeScope();
The issue is that it works when the constructor is called once, but when the constructor is called again the interface has been disposed, the constructor is as seen below -
public ClientHub()
{
this._connectionService = EngineContext.Current.Resolve<IConnectionService>();
}
By default NopCommerce has a lot of registered interface already so I have tried using what looks like a cached version
builder.RegisterType<CustomerActivityService>().As<ICustomerActivityService>()
.WithParameter(ResolvedParameter.ForNamed<ICacheManager>("nop_cache_static"))
.InstancePerLifetimeScope();
But I still get an error when trying to use the ConnectionService like this.
I have tried using multiple different methods on the builder such as
InstancePerHttpRequest();
and
InstancePerDependency();
But it's all being disposed of when the constructor is called a second time, I did head over to the NopCommerce for any help but no luck.
Any guidance / help would be amazing !
well, that may create an issue, you're trying to resolve dependency, but that messed up.
It could be:
Or either it could be only:
And not in constructor.