-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception when using Lamar #181
Comments
Hi Drol, public ProcessInfoCPUMetricsProvider(
IProcessProvider processProvider,
ILogger<ProcessInfoCPUMetricsProvider> logger,
(DateTimeOffset, TimeSpan)? initialSnap = null,
Func<int> getProcessorCount = null) Generally, if there's a way to satisfy the constructors with the default parameters, it should work. A guess is that Lamar doesn't how to satisfy the delegate of getProcessorCount, and it doesn't leverage the default of null, thus the exception upon building the dependency graph to resolve the service. Please seek help from Lamar to see if there's a way to satisfy the dependency. |
Thanks for the quick reply. Yes we use Lamar for IoC. For anyone having the same problem. You can solve it by adding this line. Taken from JasperFx/lamar#352 The author of Lamar says "The real issue here being that the optional constructor argument should be ignored? I'll get around to this at some point, but I'd point at foolish design on their part for DI usage." @ JasperFx/lamar#352 I don't want to point fingers but maybe you could make a change for this to make it work with Lamar (and possibly other IoC)? Best regards |
Hey @Drol, Thanks for the update. I agree that it is a bad design (and it was coded by me). I will bring this to the team for triage to see if we can prioritize a fix. |
Thanks @xiaomi7732 :-) |
Update: There will be a release for 2.5.1-beta in 1 to 2 weeks. |
This should have been fixed. Please check it out in Please feel free to file a new issue if there are more issues. |
Stable package released: |
Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Lamar.IoC.LamarMissingRegistrationException: No service registrations exist or can be derived for int at Lamar.IoC.Scope.GetInstance(Type serviceType) at Lamar.IoC.Scope.GetInstance[T]() at Microsoft.ServiceProfiler.Orchestration.MetricsProviders.ProcessInfoCPUMetricsProvider..ctor(IProcessProvider processProvider, ILogger
1 logger, Nullable1 initialSnap, Func
1 getProcessorCount)--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at Lamar.IoC.Instances.ConstructorInstance.quickResolve(Scope scope)
at Lamar.IoC.Instances.ConstructorInstance.<>c__DisplayClass15_0.b__0(Scope s)
at Lamar.ServiceGraph.<>c__DisplayClass48_0.b__0(Scope s)
at Lamar.IoC.Scope.GetInstance(Type serviceType)
at Lamar.Container.Microsoft.Extensions.DependencyInjection.ISupportRequiredService.GetRequiredService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Microsoft.ApplicationInsights.Profiler.Core.Orchestration.MetricsProviders.MetricsProviderResolver.Resolve(MetricsProviderCategory category)
at Microsoft.ApplicationInsights.Profiler.Core.Orchestration.ResourceUsageSource..ctor(IMetricsProviderResolver
1 metricsProviderResolver, CpuTriggerSettings cpuTriggerSettings, MemoryTriggerSettings memoryTriggerSettings, ISerializationProvider serializer, ILogger
1 logger)--- End of inner exception stack trace ---`
The text was updated successfully, but these errors were encountered: