guryanovev / CrystalQuartz

pluggable UI for Quartz.NET
MIT License
999 stars 312 forks source link

System.InvalidOperationException: Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead. #87

Closed stephen-swensen closed 4 years ago

stephen-swensen commented 4 years ago

Getting this error at startup with ASP.NET Core 3.1 / WebAPI

System.InvalidOperationException: Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead.
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpResponseStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at CrystalQuartz.WebFramework.Request.AbstractFileRequestHandler.<>c__DisplayClass4_0.<WriteResourceToStream>b__0(Stream outputStream)
   at CrystalQuartz.AspNetCore.AspNetCoreResponseRenderer.Render(Response response)
   at CrystalQuartz.WebFramework.RunningApplication.Handle(IRequest request, IResponseRenderer renderer)
   at CrystalQuartz.AspNetCore.CrystalQuartzPanelMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
alex-erygin commented 4 years ago

@stephen-swensen, you should configure Kestrel (more details):

public void ConfigureServices(IServiceCollection services)
{
    // If using Kestrel:
    services.Configure<KestrelServerOptions>(options =>
    {
        options.AllowSynchronousIO = true;
    });
}
stephen-swensen commented 4 years ago

Thanks - I'm no longer in a position to verify whether this works, but I'll trust it does and close this issue.

Timovzl commented 3 years ago

Configuring Kestrel to AllowSynchronousIO is a workaround, not a solution.