Closed sstrink closed 5 years ago
I hate the aspnet core team is my first thought here. This isn't going to get fixed quickly if you need to switch IoC tools. Lamar's basic model doesn't deal well with internal
types and I honestly didn't realize how prevalent the usage of internal types in IoC containers was before I built Lamar.
I have an existing aspnetcore solution, 2.2.105 sdk, using Lamar and I recently added the new healthcheck api to my solution. I am using the 2.1.0 version of Lamar with the latest version of the healthchecks api (2.2.x) and healthchecks ui (2.2.19) projects.
In my ConfigureContainer method I am registering healthchecks for redis, sql server, and publishing to application insights.
Then adding
In my Configure method I register the following hooks:
The healthcheck UI calls a service with the route /healthchecks-api that returns all of the above healthcheck urls I register. When Lamar is used I receive the following error in my output from the healthchecks-api call. If Lamar is removed from the solution, the healthchecks api and UI work fine.
Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request starting HTTP/1.1 GET http://localhost:17811/healthchecks-api
Microsoft.AspNetCore.HostFiltering.HostFilteringMiddleware:Trace: All hosts are allowed. Microsoft.AspNetCore.Routing.Matching.DfaMatcher:Debug: No candidates found for the request path '/healthchecks-api' Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware:Debug: Request did not match any endpoints Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware:Debug: The request path does not match the path filter Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware:Error: An unhandled exception has occurred while executing the request.
System.InvalidOperationException: Compilation failures!
CS0122: 'HealthChecksDb' is inaccessible due to its protection level
Code:
using System; using System.Threading.Tasks;
namespace Jasper.Generated { // START: HealthChecks_UI_Core_Data_HealthChecksDb_healthChecksDb public class HealthChecks_UI_Core_Data_HealthChecksDb_healthChecksDb : Lamar.IoC.Resolvers.ScopedResolver
}
at LamarCompiler.AssemblyGenerator.Generate(String code) at LamarCompiler.GeneratedAssembly.CompileAll(IServiceVariableSource services) at Lamar.IoC.Instances.GeneratedInstance.buildResolver(Scope scope) at Lamar.IoC.Instances.GeneratedInstance.ToResolver(Scope topScope) at Lamar.ServiceGraph.FindResolver(Type serviceType) at Lamar.IoC.Scope.TryGetInstance(Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider) at HealthChecks.UI.Middleware.UIApiEndpointMiddleware.InvokeAsync(HttpContext context) at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context) Application Insights Telemetry: {"name":"Microsoft.ApplicationInsights.Dev.c63d34963c49429ba2056dad00e4ac45.Exception","time":"2019-03-14T15:39:18.9669103Z","iKey":"c63d3496-3c49-429b-a205-6dad00e4ac45","tags":{"ai.application.ver":"1.0.0.0","ai.cloud.roleInstance":"ALSSTRINK-01","ai.operation.id":"7c3d427096acca469ddc44ea7d3bdf13","ai.operation.parentId":"|7c3d427096acca469ddc44ea7d3bdf13.68b8c6a2_","ai.operation.name":"GET /healthchecks-api","ai.location.ip":"::1","ai.internal.sdkVersion":"aspnet5c:2.6.1","ai.internal.nodeName":"ALSSTRINK-01"},"data":{"baseType":"ExceptionData","baseData":{"ver":2,"exceptions":[{"id":7657598,"outerId":0,"typeName":"System.InvalidOperationException","message":"Compilation failures!\n\nCS0122: 'HealthChecksDb' is inaccessible due to its protection level\n\nCode:\n\nusing System;\r\nusing System.Threading.Tasks;\r\n\r\nnamespace Jasper.Generated\r\n{\r\n // START: HealthChecks_UI_Core_Data_HealthChecksDb_healthChecksDb\r\n public class HealthChecks_UI_Core_Data_HealthChecksDb_healthChecksDb : Lamar.IoC.Resolvers.ScopedResolver