Cant load license in Single-file bundle

I may have missed how to do this in the docs. (apologies if I did). So I had a Lambda (and Azure Functions) app that was loading the license fine. I have converted this to use a single-bundle executable on linux and when I do I get
Failed to set license. Details: CodeBase is not supported on assemblies loaded from a single-file bundle.
is there a proper way to load the license. I’m using

            var license = new License();
            license.SetLicense("Aspose.Email.NET.lic");   <--- this line fails

@gpinkham

When using a single-file bundle executable on Linux, loading the license file directly can lead to issues, as you’ve encountered. The error message indicates that the CodeBase is not supported for assemblies loaded from a single-file bundle.

To properly load the license in this scenario, you can embed the license file as a resource in your application and then load it from the stream. Here’s a sample code snippet to illustrate this:

using System.IO;
using System.Reflection;
using Aspose.Email;

public void LoadLicense()
{
    var license = new License();
    var assembly = Assembly.GetExecutingAssembly();
    var resourceName = "YourNamespace.Aspose.Email.NET.lic"; // Adjust the namespace and file name

    using (Stream stream = assembly.GetManifestResourceStream(resourceName))
    {
        if (stream == null)
        {
            throw new FileNotFoundException("License file not found.");
        }
        license.SetLicense(stream);
    }
}

Make sure to replace "YourNamespace.Aspose.Email.NET.lic" with the actual namespace and name of your license file. This approach allows you to successfully load the license without encountering the limitations of the single-file bundle.

Thanks. I’ll give this a go. sadly I had changed the build to a non single file bundle and now changing back to the single file bundle; it won’t build. once I figure that out I should be good to go with the stream option. (which I also now see in the docs! )

thanks again
Gary

Hello @gpinkham,

You’re welcome! Glad you found it in the docs too, that should make things easier.

Thank you.