Autofac.ServiceFabric
Autofac.ServiceFabric copied to clipboard
Singleton does not play nicely with ServiceContext dependency
Hi,
I just recently added a logger into my service fabric application to log all service fabric communication. Because of this, it is dependent on ServiceContext. When I register my type that is dependent (on something that is dependent on something) on ServiceContext as a SingleInstance, when the Service resolve's said type I get "The requested service 'System.Fabric.ServiceContext' has not been registered".
If i remove "SingleInstance()" from the registration, everything works business as usual. Now, making my service not a singleton, isn't the worst thing in the world, but i would love for it to function as a Singleton.
I've tried injecting it as a "Lazy<T>", and a Func<Lazy<T>>, and all result in the same error. Any ideas?
Autofac.ServiceFabric 2.2.0 ServiceFabric 3.4.641
Stack trace:
at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable1 parameters) at Autofac.ResolutionExtensions.Resolve[TService](IComponentContext context, IEnumerable
1 parameters)
at Fake.ApplicationInsights.Autofac.RegistrationExtension.<>c__DisplayClass1_01.<RegisterFakeApplicationInsights>b__1(IComponentContext c) in C:\Users\matth\Documents\Fake Code\FakeShared\Fake.ApplicationInsights\Source\Fake.ApplicationInsights\Autofac\RegistrationExtension.cs:line 59 at Autofac.Builder.RegistrationBuilder.<>c__DisplayClass0_0
1.<ForDelegate>b__0(IComponentContext c, IEnumerable1 p) at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable
1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters, Object& decoratorTarget)
Thanks!
Same issue. Any updates?