Pdf License 3.0 no longer works when we updated from .net 5.0 to 8.0
Other licenses still work.
Exception of type ‘System.Exception’ was thrown.’
Issue
After moving the project from .NET 5 to .NET 8 the Aspose.PDF 3.0 license file throws
Exception of type 'System.Exception' was thrown.
All other Aspose‑PDF licenses (for example, older 2.x or newer 4.x files) work correctly.
Why it happens
- Aspose.PDF 3.0 license files are tied to the API version that created them.
- When you run the code on .NET 8 you are most likely using a newer Aspose.PDF for .NET NuGet package (e.g., 23.x).
- The 3.0 license format cannot be interpreted by the newer DLLs, therefore the runtime throws a generic
System.Exception
.
Recommended Fixes
1. Upgrade the license file (recommended)
-
Log in to the Aspose Customer Portal → My Products → Licenses.
-
Locate the license that currently contains the 3.0 version.
-
Click Regenerate / Re‑issue the license.
- Choose the same product (Aspose.PDF) and the same license type (evaluation, developer, or production).
- The portal will generate a new .lic file (version 4.0 or later) that is compatible with all current Aspose.PDF releases.
-
Replace the old
Aspose.Pdf.lic
in your project with the newly downloaded file.
Result: The same license key works on .NET 5, .NET 6, .NET 7, and .NET 8 without any code change.
2. Use the same Aspose.PDF version that created the 3.0 license (only if you cannot regenerate)
If you must keep the old license file for some reason, run the code with a matching Aspose.PDF DLL version (the one that generated the 3.0 license).
Typical steps:
<!-- In your .csproj -->
<PackageReference Include="Aspose.PDF" Version="20.12.0" />
- This version works on .NET 5 and .NET 6, but is not officially supported on .NET 8.
- You may encounter other runtime issues, so this approach is only a temporary workaround.
3. Verify that the license is loaded before any PDF operation
using Aspose.Pdf;
public class Startup
{
public void Configure()
{
// Must be the very first Aspose.Pdf call
var license = new License();
license.SetLicense("Aspose.Pdf.lic"); // Path relative to the executing assembly
// Now you can safely use Aspose.Pdf classes
var doc = new Document("sample.pdf");
// ...
}
}
- Ensure the
.lic
file is set to Copy to Output Directory → Copy always (or Copy if newer). - If you load the license after the first
Document
creation, the library will already have thrown the exception.
Additional Resources
Topic | Link |
---|---|
How to set a license for Aspose.PDF for .NET | Aspose PDF License|Aspose.PDF for .NET |
Regenerating a license file | Purchase Portal |
Supported .NET versions for Aspose.PDF | https://docs.aspose.com/pdf/net/supported-platforms/ |
Troubleshooting license issues | https://docs.aspose.com/pdf/net/license-troubleshooting/ |
Next Steps for You
- Regenerate the license in the Aspose portal (the quickest, most future‑proof solution).
- Replace the old
Aspose.Pdf.lic
file in your project and rebuild. - Run the application on .NET 8 – the license should now be applied without the exception.
If you still encounter the error after regenerating the license, please reply with:
- The exact version of the Aspose.PDF NuGet package you are using.
- A minimal code snippet that reproduces the exception (including the
License.SetLicense
call).
I’ll be glad to dive deeper with you.
If we don’t have the active license for updates only the old one can we still do the step 2 to create new license? Also we are still using same nuget package which is 20.10.0
Have you tried new license with the latest available version of the API i.e. 25.8? Can you please share complete stack trace information if you are facing this error with the latest version? The error you shared can also be related to support of .NET 8.0 which is not present in the older API versions.