1

When we deploy the apps with missing dependencies we are getting 500 errors but not very helpful. We can not capture the error with appinsight as the app does not start. How can we have a better error?

Adding Build task as Index Sources & Publish Symbols would that help ?

About the app - .net core - Views are not precomplied.

Azure detailed errors and appinsights enabled with nlog.

Generic Error is like

http://www.w3.org/1999/xhtml”> IIS Detailed Error - 500.0 - Internal Server Error

Rıfat Erdem Sahin
  • 1,738
  • 4
  • 29
  • 47

2 Answers2

1

I suggest installing Application Insights. You can then get very detailed messages on exceptions and app performance in general, both on the client and server side. Integrating it is really easy and can be done through Visual Studio.

Rob Reagan
  • 7,313
  • 3
  • 20
  • 49
0

two steps to solve the problem

step 1 . var host = new WebHostBuilder().CaptureStartupErrors(true)

step 2 . create logs folder

step 3 . add a class to get reflection errors.

Step 4 . goto kudu and enable logging at web.config

step 5 . Find the error in and see the related dependency.

Step 6 . Write a nuget as .core loves nugets but hates direct dependencies.

 public class ReflectionTypeLoadExceptionLoggingMiddleware
    {
        private readonly RequestDelegate _next;
        private readonly Microsoft.Extensions.Logging.ILogger _logger;
        public ReflectionTypeLoadExceptionLoggingMiddleware(RequestDelegate next, ILoggerFactory loggerFactory)
        {
            _next = next;
            _logger = loggerFactory.CreateLogger<ReflectionTypeLoadExceptionLoggingMiddleware>();
        }
        public async Task Invoke(HttpContext httpContext)
        {
            try
            {
                await _next(httpContext);
            }
            catch (Exception ex)
            {
                var reflectionTypeLoadException = ex as ReflectionTypeLoadException;
                if (reflectionTypeLoadException != null && reflectionTypeLoadException.LoaderExceptions != null)
                {
                    _logger.LogError("ReflectionTypeLoadException {0}", ex);
                    _logger.LogError("Loader exceptions messages: ");
                    foreach (var exception in reflectionTypeLoadException.LoaderExceptions)
                    {
                        _logger.LogError("ex {0}", exception);
                    }
                }
                throw;
            }
        }
    }
Rıfat Erdem Sahin
  • 1,738
  • 4
  • 29
  • 47