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!