Not sure I got it but I already have this in appsettings in both production and dev.
"SwaggerUIEnabled": "false"
Swagger isn't accessible in prod.
Do you mean just omit the line bool.Parse(_appConfiguration["App:SwaggerUIEnabled"]) ?
Should the ON/OFF I have in appsettings enable/disable without the If statement I added?
Hi @maliming
It's enabled in dev mode but disabled in production. Not sure if it's the correct way to disable Swagger in production?
I get this error in production
Thanks
Sent to your email.
Hi
I got another type of unhandled exception. This time is about Swagger:
e.Diagnostics.ExceptionHandlerMiddleware - An unhandled exception has occurred while executing the request. System.InvalidOperationException: Unable to resolve service for type 'Swashbuckle.AspNetCore.Swagger.ISwaggerProvider' while attempting to Invoke middleware 'Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware'. at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.GetService(IServiceProvider sp, Type type, Type middleware) at lambda_method(Closure , Object , HttpContext , IServiceProvider ) at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context) at Abp.AspNetZeroCore.Web.Authentication.JwtBearer.JwtTokenMiddleware.<>c__DisplayClass0_0.<<UseJwtTokenMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Abp.AspNetZeroCore.Web.Authentication.JwtBearer.JwtTokenMiddleware.<>c__DisplayClass0_0.<<UseJwtTokenMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context)
I researched logs already and I think I'm able to locate the 1-2 services that produce that exception. I already optimized my queries to avoid executing a query while iterating over the results from another query. Also, I stopped all background workers and jobs. All the mentioned didn't help yet and I still need to find the exact place so I better know how to fix it.
I'm still aiming for two things:
Thanks
Hi!
I got the expected crash again. Unfortunately I got in c:\logs exactly same message I got in windows event viewer. There's nothing that helps me idenfity source of problem!
The weird thing that I get logs only when I restart IIS. System crashed and was stucked for hours without any logs in c:\logs nor in event viewer.
Your urgent assistance is needed please since this problem has been negatively impacting the user experience of my users in production!
Thanks a lot Alper! I added your code to Startup(IHostingEnvironment env) method and deployed to production. I've created Logs folder in c:\ with IUSR permissions. I'm now waiting the next crash to check logs!
Thank you @alper and @ismcagdas
I don't have async void.
Everytime system crashes I get the following two errors in windows event viewer:
Application: MyApp.Web.Host.exe CoreCLR Version: 4.6.27817.3 Description: The process was terminated due to an unhandled exception. Exception Info: System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first. at System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command) at System.Data.SqlClient.SqlInternalTransaction.Rollback() at System.Data.SqlClient.SqlTransaction.Dispose(Boolean disposing) at Microsoft.EntityFrameworkCore.Storage.RelationalTransaction.Dispose() at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.ClearTransactions() at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Dispose() at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.Dispose() at Microsoft.EntityFrameworkCore.DbContext.Dispose() at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.ApplyConcerns(IEnumerable`1 steps, Object instance) at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Destroy(Object instance) at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Release(Object instance) at Castle.MicroKernel.Burden.Release() at Castle.MicroKernel.Releasers.LifecycledComponentsReleasePolicy.Dispose() at Castle.MicroKernel.DefaultKernel.Dispose() at Microsoft.AspNetCore.Hosting.Internal.WebHost.Dispose() at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String shutdownMessage) at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token) at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host) at MyApp.Web.Startup.Program.Main(String[] args) in C:\code\MyApp\aspnet-core\src\MyApp.Web.Host\Startup\Program.cs:line 11
Faulting application name: MyApp.Web.Host.exe, version: 0.0.0.0, time stamp: 0x5c414d46 Faulting module name: KERNELBASE.dll, version: 6.3.9600.19425, time stamp: 0x5d26b6e9 Exception code: 0xe0434352 Fault offset: 0x000000000000908c Faulting process id: 0x17e0 Faulting application start time: 0x01d56396ebf75622
Can you please tell me where exactly in Startup.cs I should add the code posted by @Alper ? Are you referring to Startup.cs in web.host?
Sorry another question. I feel it's hard to find unhandled exception and I really don't want the app in production to crash. I need your help in the following:
A possible fix for Open DataReader problem is enabling MARS https://docs.microsoft.com/en-us/sql/relational-databases/native-client/features/using-multiple-active-result-sets-mars?view=sql-server-2017
Do you recommend doing so?