Hello,
I’m receiving the following error trying to open a workbook stream in Aspose.Cells 25.6 in Blazor WebAssembly. I believe Thread.Start is not available in WebAssembly.
Operation is not supported on this platform.
blazor.web.js:1 at System.Threading.Thread.ThrowIfNoThreadStart(Boolean internalThread)
blazor.web.js:1 at System.Threading.Thread.Start(Boolean captureContext, Boolean internalThread)
blazor.web.js:1 at System.Threading.Thread.Start()
blazor.web.js:1 at .(Int64 , Boolean )
blazor.web.js:1 at .(Int64 )
blazor.web.js:1 at e.(Int64 )
blazor.web.js:1 at .()
blazor.web.js:1 at .(String , Stream , LoadOptions )
blazor.web.js:1 at Aspose.Cells.Workbook.(Stream , LoadOptions , Boolean )
blazor.web.js:1 at Aspose.Cells.Workbook…ctor(Stream stream)
Thank you,
-Andy
@weissa
Cause
The error you’re encountering, “Operation is not supported on this platform,” is due to the limitations of Blazor WebAssembly, which does not support multi-threading in the same way as traditional .NET applications. Specifically, the Thread.Start
method is not available in this environment, leading to the issue when trying to open a workbook stream.
Solution
To work around this limitation, you can use asynchronous programming patterns instead of relying on threads. Instead of using Thread.Start
, consider using async
and await
to handle your workbook operations. This will allow you to perform tasks without blocking the UI thread.
Code
Here’s a simple example of how you might modify your code to use asynchronous methods:
using Aspose.Cells;
using System.IO;
using System.Threading.Tasks;
public async Task LoadWorkbookAsync(Stream stream)
{
// Ensure the stream is not null and is readable
if (stream == null || !stream.CanRead)
throw new ArgumentException("Stream is not readable.");
// Use Task.Run to offload the workbook loading to a background task
await Task.Run(() =>
{
Workbook workbook = new Workbook(stream);
// Perform additional operations with the workbook here
});
}
Next Steps
- Replace any direct calls to
Thread.Start
with asynchronous methods.
- Ensure that your UI remains responsive by using
async
and await
for any long-running operations.
- Test your application to confirm that the workbook loads correctly without the threading error.
If you follow these steps, you should be able to resolve the issue effectively. Please let me know if you need further assistance!
@weissa ,
To make sure the same issue can be reproduced, please share us a sample runnable Blazor WebAssembly project with code and source file.
@peyton.xu ,
No problem. I followed the instructions on this page (How to Run Aspose.Cells in Blazor|Documentation) and was able to reproduce the issue immediately. Build and serve the project and through WASM and then press the Run Aspose Tests to reproduce the error.
BlazorApp1.zip (1.4 MB)
Thank you,
-Andy
@weissa ,
Please spare us some time to evaluate your issue, we will be back with updates.
@weissa
We can reproduce and locate the issue as your mentioned, the exception ‘Operation is not supported on this platform’ occurs.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CELLSNET-58686
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
@weissa,
We are pleased to inform you that your issue (Ticket: “CELLSNET-58686 - ‘Operation is not supported on this platform’ exception occurs while opening workbook in Blazor WebAssembly”) has been resolved. The fix/enhancement will be included in the upcoming release (Aspose.Cells v25.7) that we plan to release in the first half of July 2025. You will be notified when the next version is published.
The issues you have found earlier (filed as CELLSNET-58686) have been fixed in this update. This message was posted using Bugs notification tool by leoluo