Licensing Aspose.Diagram using reflection

Hi,

I’m trying to embed the Aspose.Diagram assembly as an embedded resource in a WinForms application and load it dynamically using reflection. It seems to work, but when I try to license the application by invoking the SetLicense method I get the following exception:

Exception thrown: ‘System.FormatException’ in Unknown Module.
Additional information: Invalid length for a Base-64 char array.

Here’s my code:

byte[] asposeData;
using (Stream stream = assembly.GetManifestResourceStream(resourceName))
{
	asposeData = NStreamHelpers.ReadToEnd(stream);
}

Assembly asposeDiagram = Assembly.Load(asposeData);
AsposeLicenseType = asposeDiagram.GetType("Aspose.Diagram.License");
AsposeLicenseSetLicenseMethod = AsposeLicenseType.GetMethod("SetLicense", new Type[] { typeof(Stream) });

object license = Activator.CreateInstance(AsposeLicenseType);
AsposeLicenseSetLicenseMethod.Invoke(license, new object[] { stream });

I get the exception at the last line of the code, i.e. when I invoke the SetLicense method.

The stream that contains the license is correct and the same code (but called directly without reflection) works fine:

Aspose.Diagram.License license = new Aspose.Diagram.License();
license.SetLicense(stream);

Please let me know is it possible to activate and use the Aspose.Diagram assembly via reflection. Thank you in advance!

@pavel_nevron,

We are unable to replicate this error in our environment. Kindly create a small application project and make sure that it reproduces this error in your environment, and then send us a Zip of this project. We will investigate and share our findings with you.

Thanks for the quick response. This is a bit strange, but after the Windows 10 update I received today, the code I’ve shared above works fine. Maybe the update applied some fixes to the .NET framework or something else in Windows that was causing the problem.

@pavel_nevron,

It is nice to hear from you that the problem has been resolved after the Windows 10 update. Please feel free to let us know whenever you require any further assistance.