I'm having trouble getting the 4.9 version to accept my license. Here's my class library code with notes:
namespace AsposeTestLib
{
public static class AsposeManager
{
const string LICENSE_FILE = "AsposeTestLib.Resources.Aspose.Total.lic";
private static readonly System.Reflection.Assembly _assembly = typeof(AsposeManager).Assembly;
private static readonly Aspose.Pdf.License _asposePdfLicense = new Aspose.Pdf.License();
//
// Aspose.Pdf.dll (4.9) - Fails with TypeInitializationException / VerificationException : Target=32 & 64|Release, OS=64bit, .Net 4.0 Full
// Aspose.Pdf.dll (4.7) - Works!
//
public static void InitializeWithStream()
{
using (var stream = _assembly.GetManifestResourceStream(LICENSE_FILE))
{
if (stream != null)
_asposePdfLicense.SetLicense(stream);
else
throw new System.ApplicationException(System.String.Format("Unable to find Aspose license resource stream '{0}' in assembly '{1}'", LICENSE_FILE, _assembly.GetName()));
}
}
//
// Aspose.Pdf.dll (4.9) - Fails with TypeInitializationException / VerificationException : Target=32 & 64|Release, OS=64bit, .Net 4.0 Full
// Aspose.Pdf.dll (4.7) - Fails with FileNotFoundException 'LICENSE_FILE' : Target=64 only|Release, OS=64bit, .Net 4.0 Full
// It only seems to fail outside of the debugger on this one.
//
public static void InitializeWithPath()
{
_asposePdfLicense.SetLicense(LICENSE_FILE);
}
}
}
Here is the test application that runs it:
namespace AsposeTest
{
class Program
{
private const string TEST_PDF = @"C:\HelloWorld.pdf";
static void Main()
{
System.Console.WriteLine("Current process is {0}-bit.", System.IntPtr.Size * 8);
//
// INITIALIZE ASPOSE PDF WITH LICENSE
//
AsposeTestLib.AsposeManager.InitializeWithPath();
System.Console.WriteLine("License manager successfully initialized.");
//
// CREATE A TEST PDF
//
CreateTestPdf();
if (!System.IO.File.Exists(TEST_PDF))
{
throw new System.IO.FileNotFoundException("File not found", TEST_PDF);
}
System.Console.WriteLine("Test PDF file created successfully.");
//
// END
//
System.Console.WriteLine();
System.Console.WriteLine("Test successful");
System.Console.ReadLine();
}
private static void CreateTestPdf()
{
var pdf = new Aspose.Pdf.Pdf();
var section = pdf.Sections.Add();
section.Paragraphs.Add(new Aspose.Pdf.Text("Hello World!"));
pdf.Save(TEST_PDF);
}
}
}
Here are the two different stack traces I'm getting. For the 4.7 issue:
Unhandled Exception: System.IO.FileNotFoundException: Cannot find license 'AsposeTestLib.Resources.Aspose.Total.lic'.
at x21e4a7ad326d8315.x220f433da4115056.xde6236852622c268(String x1c1fc72fe1a3b4ea, Assembly x39e0a96279c40baa, Boolean x77c11057a70ce853)
at x21e4a7ad326d8315.x220f433da4115056.x7d0214bf69711dd9(String x1c1fc72fe1a3b4ea, Assembly x5807f920b6fc67c4)
at Aspose.Pdf.License.SetLicense(String licenseName)
at AsposeTest.Program.Main() in C:\Users\myname\Documents\Visual Studio 2010\Projects\AsposeTest\AsposeTest\Program.cs:line 21
For the 4.9 issues:
Unhandled Exception: System.TypeInitializationException: The type initializer for '☺.♣' threw an exception. ---> System.Security.VerificationException: Operation could destabilize the runtime.
at (Object , String )
at ☺.♣..cctor()
--- End of inner exception stack trace ---
at ☺.♣.⌂(Int32 )
at Aspose.Pdf.License.SetLicense(String licenseName)
at AsposeTest.Program.Main() in C:\Users\myname\Documents\Visual Studio 2010\Projects\AsposeTest\AsposeTest\Program.cs:line 17
Sorry about the formatting, I couldn't figure out how to make it look nicer. We are rolling back our library to 4.7 and the InitializeWithStream method to get our clients working, but I wanted to understand why we aren't able to upgrade to the 4.9 version.
Thank you in advance!