Set license in Blazor WASM

How do I set the Aspose Words liense in Blazor WASM?

In Blazor Server, I have done it succesfully by putting my lic file in the root folder of the project and setting it as an embedded resource.
In Startup.cs, I create the License object and call SetLicense.

In a WASM project, I again put the lic file as an embedded resource in the project root folder.
I put the same line of code to call SetLicense in Program.cs, but when I debug the program, I get an error

System.ArgumentNullException: Value cannot be null. (Parameter ‘uriString’)

Who knows how to set the license?

Thanks,
Tim

@TimDol Could you please share your code you use for setting the license and also stack trace of the exception?
You can try setting the license from stream, i.e. extract your embedded resource into a stream and pass this stream as a parameter to License.Setlicense method.

SOLVED

To help others:

Could you please share your code you use for setting the license

What I was trying to do initially, was:

  • Put my .lic file in the project root folder and set the Build action to ‘Embedded resource’

  • In Program.cs, I had the following two lines of code
    Aspose.Words.License lic = new Aspose.Words.License();
    lic.SetLicense(“Aspose.Words.NET.lic”);

Based on the feedback, I kept the .lic file as embedded resource, but changed the code to this:

var assembly = Assembly.GetExecutingAssembly();
var resourceName = "<logical name set in .csproj file>";

using (Stream stream = assembly.GetManifestResourceStream(resourceName))
{
    Aspose.Words.License lic = new Aspose.Words.License();
    lic.SetLicense(stream);
}

@TimDol It is perfect that you managed to solve the problem on your side. Please feel free to ask in case of any issues. We will be glad to help you.