Hello,
The class:
DevExpress.Export.Xl.IXlDocument
Does not implement:
IAsyncDisposable
This causes an error when disposing the object from an async method. As the direction of travel with C# is everything is moving async, could I please request that the IAsyncDisposable is implemented for this class?
This issue is present on the latest version, 24.2.5.
Example code:
C#public static async Task CreateExcelFileAsync(XlDocumentFormat format, Stream responseStream, IAsyncEnumerable<IDictionary<string, object?>> values)
{
IXlExporter exporter = XlExport.CreateExporter(format);
using (IXlDocument document = exporter.CreateDocument(responseStream))
{
// .. logic
} // Error here on the dipose
}
Hi,
Thank you for the report. We will investigate this issue and get back to you once we have news.
Hi,
I couldn't reproduce the issue on my side. Please refer to the attached project. As you can see, the XlExport library creates an XLSX file and the issue doesn't occur. Would you please modify the attached project to illustrate the issue?
I look forward to your response.
Hi Sasha,
Please see attached.
There is a workaround, as below code to allow synchronous IO, but this is using a sledgehammer to crack a walnut. I don't believe that there's a lot of work in implementing the IAsyncDisposable interface, which would be a much nicer solution.
// Need this for: IXlDocument. It won't dispose otherwise, DevExpress issue services.Configure<KestrelServerOptions>(options => { options.AllowSynchronousIO = true; }); // Need this for: IXlDocument. It won't dispose otherwise, DevExpress issue services.Configure<IISServerOptions>(options => { options.AllowSynchronousIO = true; });
Edit: I didn't realise the other project reference hadn't been removed. It's not required for the example. To clarify, the error occurs as below screenshot, if you just run it up and execute the endpoint in Swagger![Clipboard-File-2.png]()
Hi,
Thank you for the sample project. We need additional time to research it. I will update this thread once we have news.