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;
}
}
}