Error When creating New Page using PowerShell

I am getting an error when trying to create a new PDF. The error I am getting is:

The following exception occurred while retrieving member "Pages": "Type handle 'Aspose.Pdf.Document' and method handle with declaring type '#=zcZyNz6VvJbJ25b0I32Qh$4ByTWpA' are incompatible. Get RuntimeMethodHandle and declaring RuntimeTypeHandle off the same MethodBase."

Here is the code below:

Add-Type -Path "$scriptLocation\AsposePDF\Aspose.PDF.dll"
$scriptLocation = "C:\Temp
$license = New-Object Aspose.Pdf.License
$license.SetLicense("$scriptLocation\AsposePDF\Aspose.PDF.NET.lic")

#Setup PDF documents
$pdfDocument = New-Object Aspose.Pdf.Document
$page = $pdfDocument.Pages.Add()
$page.PageInfo.IsLandscape = $true

$pdfDocument.Save("$outputLocation$outputFileName")

I am not sure how to troubleshoot or solve the issue.

@peter122342

Can you please share the PowerShell version and the API version you are working with? We will further try to test the scenario in our environment and address it accordingly.

This is the powershell version
Name Value


PSVersion 5.1.19041.4412
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
BuildVersion 10.0.19041.4412
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

I am using Aspose.PDF version 22.8.0.

@peter122342

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-57518

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.