License location in .net 8

I’m updating a site from .net 4.6 to a .net 8 core mvc site. I’ve tried to place the aspose license in the bin folder of the new site, but i’m still seeing the Evaluation message and watermark. Can someone advise the correct way to install aspose.words in a .net 8 core mvc site?

@jasoncurley

To properly apply the Aspose.Words license in your .NET 8 Core MVC application, follow these steps:

  1. Place the License File: Ensure that your license file (e.g., Aspose.Words.lic) is located in a directory that your application can access. A common practice is to place it in the root of your project or in the same directory as your executable.

  2. Set the License in Code: You need to create a License object and call the SetLicense method to apply the license. Here’s a sample code snippet demonstrating how to do this:

    using Aspose.Words;
    
    public class LicenseManager
    {
        public void ApplyLicense()
        {
            License license = new License();
            try
            {
                // Specify the path to your license file
                license.SetLicense("Aspose.Words.lic");
                Console.WriteLine("License set successfully.");
            }
            catch (Exception e)
            {
                Console.WriteLine("There was an error setting the license: " + e.Message);
            }
        }
    }
    
  3. Verify License Application: After setting the license, you can check if it has been applied successfully by using the IsLicensed property of the License class.

  4. Call License Application Early: Make sure to call the license application code early in your application startup process, before using any Aspose.Words classes. This ensures that the library operates in licensed mode from the start.

  5. Alternative Method: If you prefer, you can also load the license from a stream, which is useful if the license file is embedded as a resource. Here’s how you can do that:

    using System.IO;
    using Aspose.Words;
    
    public class LicenseManager
    {
        public void ApplyLicenseFromStream()
        {
            License license = new License();
            try
            {
                using (Stream stream = File.OpenRead("Aspose.Words.lic"))
                {
                    license.SetLicense(stream);
                    Console.WriteLine("License set successfully from stream.");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("There was an error setting the license: " + e.Message);
            }
        }
    }
    

By following these steps, you should be able to successfully apply the Aspose.Words license in your .NET 8 Core MVC application and eliminate the evaluation message and watermark.

For more detailed information, you can refer to the official documentation on applying licenses from files and streams here and here.

Sources:
[1]: Apply License From File | Aspose.Words Document Processing API
[2]: Apply License From Stream | Aspose.Words Document Processing API

@jasoncurley Also, you can consider using the license as an embedded resource?

Hi Alexey,

I just noticed when I debug the project that when the license is set in code, this error is being thrown:

System.InvalidOperationException: ‘The subscription included in this license allows free upgrades until 06 Jan 2024, but this version of the product was released on 01 Mar 2024. Please renew the subscription or use a previous version of the product.’

Can you please advise how I would resolve this?

Thanks,

Jason

~WRD0002.jpg (357 Bytes)

@jasoncurley Each Aspose license provides a 1-year subscription for free upgrades to any new Aspose product version that comes out. You can download and use any Aspose product version released before the subscription expiry date.

If you want to check when your subscription expires, open the license file in Notepad (but take care not to modify and save the license file or it will no longer work) and see the SubscriptionExpiry field.

<SubscriptionExpiry>20220218</SubscriptionExpiry>

It means that you can free upgrade to version of Aspose product published before 02/18/2022.
You can use Aspose license perpetually, unless you update Aspose product to the version, which is released after the license expiration date.

Hi Alexey,

Resending this message, not sure if you saw my previous questions.

Thanks,

Jason

~WRD0002.jpg (357 Bytes)

@jasoncurley Please see my previous answer. The exception you have mentioned occurs because your license subscription expired. So you should either renew your license or use older version of Aspose.Words which was released before the license expiration date.