Open andreas-valtech opened 1 year ago
@andreas-valtech 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.
Big thanks for the workaround @andreas-valtech :-)
I made a bug report before finding this issue. https://github.com/microsoft/ApplicationInsights-Profiler-AspNetCore/issues/181
We will see if they are willing to make a change for the problem.
I get this when profiler trying to upload to Azure. Guess it is not made for other IoC frameworks at all...
Lamar.IoC.LamarMissingRegistrationException: Unknown service registration '%SP_UPLOADER_PATH%' of string at Lamar.IoC.Scope.GetInstance(Type serviceType, String name) at Lamar.IoC.Scope.GetInstance[T](String name) at Lamar.IoC.Lazy.FuncByNameInstance
1.<>c__DisplayClass6_0.
This is now resolved by Microsoft in the above mentioned issue (https://github.com/microsoft/ApplicationInsights-Profiler-AspNetCore/issues/181). I have verified it myself and everything works as expected (without any workarounds in place) in the 2.5.2 release of Microsoft.ApplicationInsights.Profiler.AspNetCore.
This issue can be closed.
In the method
AddServiceProfiler
from the packageMicrosoft.ApplicationInsights.Profiler.AspNetCore
a dependecy on aFunc<int>
is used which crashes Lamar if no such registration is found. The built in IoC container just ignores the parameter since it has a default value.The failure happens in
ProcessInfoCPUMetricsProvider
since it cant resolve theFunc<int> getProcessorCount
dependency:I have added a workaround in my Startup.cs which works but is a bit sketchy:
Using Lamar.Microsoft.DependencyInjection version 8.0.1.
The stack trace I get without the workaround above is: