We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

SetLicense with stream from string

Hi, i’m trying to use a 30-day license (then i’ll have a real license): as read in your site pages i used a static contructor in my class library.




when i use phisical license file that way:

Aspose.Words.License oWlicense = new Aspose.Words.License();

oWlicense.SetLicense(“path_to_Aspose.Total.Lic”);




it’s ok but i need to insert license file content in a string variable and pass it as stream to license class




when i try to use this code:

System.IO.MemoryStream myStream = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(<string_variable>));

oWlicense.SetLicense(mystream);




i’m getting some errors from aspose.cells rather than aspose.words (not tried slides or Others for now):




if i use system.encoding.UTF8…

aspose.cells thow an exeption: “Object reference not set to an instance of an object.” (words works)




instead if i use system.encoding.unicode…

aspose.words throw this exeption: “Name cannot begin with the ‘.’ character, hexadecimal value 0x00. Line 1, position 40.”




There is Some way or workaround to get working this way for total libraries classes of Aspose?

thank’s a lot

Hi,

I used following code to load license from streams and did not notice any issue.

using (MemoryStream ms = new MemoryStream(File.ReadAllBytes(@"D:\AsposeAspose.Total.lic")))

{

Aspose.Words.License wLicense = new Aspose.Words.License();

wLicense.SetLicense(ms);

}

using (MemoryStream ms = new MemoryStream(File.ReadAllBytes(@"D:\Aspose\Aspose.Total.lic")))

{

Aspose.Cells.License cLicense = new Aspose.Cells.License();

cLicense.SetLicense(ms);

}<?xml:namespace prefix = "o" ns = "urn:schemas-microsoft-com:office:office" />

Best Regards,

My problem is i’can’t start from phisical file: you use a memorystream with file.readallbytes


i have to use a memorystream with some other Methow for reading bytes from a string containing license… or other way that i don’t know (store license file directly in a byte array? how?)

thank you

Hi,

You can include the license file as an embedded resource and pass license file name to SetLicense method. Please check http://www.aspose.com/docs/display/wordsnet/Including+the+License+File+as+an+Embedded+Resource for more details and let us know if this does not suit your requirement either.

Best Regards,