I’m running into an error using version 26.0 in our Blazor WebAssembly application. The error occurs when attempting to instantiate the License class.
Environment:
.NET 8.0 Blazor WebAssembly
Aspose.Words for .NET 26.0 (just upgraded from 24.1.0)
Error:
System.TypeLoadException: Could not load type of field 'U:B3' (32) due to: Could not resolve type with token 01000141 from typeref (expected class 'System.Reflection.Module' in assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') assembly:mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 type:System.Reflection.Module member:(null)
at Aspose.Words.License..ctor_2()
at Aspose.Words.License..ctor()
at Company.AsposeSupport.AsposeHelper.InitializeLicense()
Code Snippet:
private const string LicenseName = "{RootNamespace}.Aspose.Words.lic"; //This is an Embedded Resource
public static void InitializeLicense()
{
//Unlock the license for Aspose before declaring document
using (var licenseStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(LicenseName))
{
new License().SetLicense(licenseStream);
}
}
This fails when running Blazor WebAssembly running in the browser.
Questions:
Does Aspose.Words officially support Blazor WebAssembly? If so, is there a specific package or version I should use?
Are there any WASM-specific configuration steps or workarounds for licensing?
Any guidance would be greatly appreciated. Thank you!
Based on your description, here is a likely technical approach for Aspose.Words.
Provisional answer
Aspose.Words for .NET (v26.0) is built for the full .NET runtime and for .NET Core/.NET 5‑8 on the server side. It depends on APIs (e.g., System.Reflection.Module from mscorlib) that are not present in the WebAssembly runtime used by Blazor WASM, so the library cannot be loaded in the browser and you get the TypeLoadException you posted.
At the moment Aspose does not ship a Blazor‑WASM‑specific package for Aspose.Words. The supported ways to use Aspose.Words from a Blazor client are:
Option
How it works
Licensing
Server‑side processing – keep the Blazor UI in WASM but call a server‑side API (e.g., ASP.NET Core controller) that creates an Aspose.Words.Document and returns the result (PDF, DOCX, etc.).
The server runs the regular Aspose.Words .NET library, so all features and licensing work unchanged.
Use the normal embedded‑resource license on the server side.
Aspose.Words Cloud SDK – call the Aspose Cloud REST service from the WASM client (or via a thin server proxy).
The heavy processing is performed by the cloud service; the client only sends/receives streams.
Licensing is handled by the Cloud subscription (no .lic file needed).
Blazor Server – run the whole app on the server (SignalR) instead of pure WASM.
Same as server‑side processing, but the UI is rendered over SignalR.
Same as normal .NET usage.
If you must keep everything client‑side, the only viable path today is the Cloud SDK; the on‑premise .NET library cannot be used in the browser.
Typical workaround (server‑side API)
// ASP.NET Core controller running on the server
[ApiController]
[Route("api/words")]
public class WordsController : ControllerBase
{
private readonly ILogger<WordsController> _log;
public WordsController(ILogger<WordsController> log) => _log = log;
public WordsController()
{
// load the .lic file once (embedded resource or file)
using var licStream = Assembly.GetExecutingAssembly()
.GetManifestResourceStream("MyApp.Aspose.Words.lic");
new Aspose.Words.License().SetLicense(licStream);
}
[HttpPost("convert")]
public async Task<IActionResult> Convert(IFormFile doc)
{
using var stream = doc.OpenReadStream();
var document = new Aspose.Words.Document(stream);
using var outStream = new MemoryStream();
document.Save(outStream, SaveFormat.Pdf);
outStream.Position = 0;
return File(outStream, "application/pdf", "result.pdf");
}
}
The Blazor‑WASM client simply posts the file to /api/words/convert and receives the PDF.
Clarifying questions
Do you have a server component (e.g., ASP.NET Core API) that can host the Aspose.Words library, or must the entire processing stay inside the WASM client?
Would you consider using Aspose.Words Cloud (REST) instead of the on‑premise .NET library for this Blazor‑WASM scenario?
No not at the moment, we were aiming to keep this entirely in the WASM client.
Not really, part of the reason we were moving away from an app that had a server, to an app that did processing client side due to customer privacy and wanting it to be “offline” and not reliant on the internet for some of its processes.
You’re seeing a TypeLoadException because the Aspose.Words .NET library (v26.0) relies on runtime APIs such as System.Reflection.Module that aren’t available in the WebAssembly runtime used by Blazor WASM, so the assembly can’t be loaded in the browser [1].
1. Blazor WASM support
Aspose does not provide a Blazor‑WASM‑specific package for Aspose.Words. The on‑premise .NET library is built for the full .NET runtime and for .NET Core/.NET 5‑8 on the server side, and it cannot be used directly in a pure WebAssembly client [1].
2. Licensing in a WASM client
Because the library cannot be loaded in the browser, a .lic file cannot be applied client‑side. There are no WASM‑specific licensing steps; licensing works only when the library runs on a supported .NET runtime (e.g., a server) [1].
3. Offline client‑side processing
With the on‑premise Aspose.Words .NET library, offline client‑side processing is not possible. The practical options are:
Server‑side API – keep the Blazor UI in WASM but call an ASP.NET Core controller (or similar) that runs Aspose.Words and returns the result. The normal embedded‑resource license is used on the server.
Aspose.Words Cloud SDK – call the Aspose Cloud REST service (directly or via a thin proxy). This requires an internet connection but handles licensing through the cloud subscription.
Blazor Server – run the whole app on the server (SignalR) so the library and licensing work unchanged.
All of these approaches are described in the earlier response [1].
4. Next steps
If adding a lightweight server component is acceptable, create a simple ASP.NET Core controller that loads the license once and performs the required document operations, then invoke it from your WASM client. If you need a fully client‑side solution, the Aspose.Words Cloud SDK is the only viable client‑side alternative at present.
Feel free to let me know which approach you’d like to explore further, and I can help with more detailed guidance.
One quick question, why is this only happening after I publish the application (dotnet publish etc)? It’s been running fine when running locally in debug mode in Visual Studio? This is why it’s now bit of a surprise to see it not working.
@rhysie Unfortunately, as it was mentioned above, Aspose.Words does not provide a Blazor‑WASM‑specific package. I have linked your request to the appropriate feature request WORDSNET-22705. However, please note, currently we do not have plans to provide such build in the foreseeable future.
Also, I create a separate issue regarding exception upon setting the license WORDSNET-29074.