autofac / Autofac.ServiceFabric

Autofac integration for Azure Service Fabric. Provides service factory implementations for Actors, Stateful Services and Stateless Services.
MIT License
26 stars 27 forks source link

Singleton does not play nicely with ServiceContext dependency #51

Open MattHartz opened 5 years ago

MattHartz commented 5 years ago

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", and a Func<Lazy>, 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, IEnumerable1 parameters) at Fake.ApplicationInsights.Autofac.RegistrationExtension.<>cDisplayClass1_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_01.b0(IComponentContext c, IEnumerable1 p) at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters) at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters, Object& decoratorTarget)

Thanks!

balbelias commented 3 years ago

Same issue. Any updates?