Re: Aspose PDF License related

Also here is the exception details we have seen :-

<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:DontVertAlignCellWithSp/>
<w:DontBreakConstrainedForcedTables/>
<w:DontVertAlignInTxbx/>
<w:Word11KerningPairs/>
<w:CachedColBalance/>
</w:Compatibility>
<w:DoNotOptimizeForBrowser/>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–>

Exception

System.NullReferenceException: Object reference not set to an instance of an object.

at Aspose.Pdf..(Stream ֒)

at Aspose.Pdf..(String , Assembly )

at Aspose.Pdf.License.SetLicense(String licenseName)

This happens only sometimes now always so license file is present at the location.

Hi Harshal,


Sorry for the inconvenience faced. Please download and try latest Aspose.Pdf API, hopefully your issue will be resolved as we have made some license related fixes in last releases.

Please feel free to contact us for further assistance.

Best Regards,

Hi Tilal,

We upgraded to the latest Aspose pdf dll version but still seeing the below error for multithreaded scenarios.

part of the Sample code :-

Aspose.Pdf.License _AsposeLicense = new Aspose.Pdf.License();
_AsposeLicense.SetLicense(“Aspose.Pdf.lic”);


Exception message

System.NullReferenceException: Object reference not set
to an instance of an object.

at Aspose.Pdf..(Stream ֒)

at Aspose.Pdf..(String , Assembly )

at Aspose.Pdf.License.SetLicense(String licenseName)


Some of the observation are as follows :-

Resetting the application pool (in which the above code runs fixes the issue. Can it be something related to memory leak or maybe license file getting locked since multiple thread are accessing the same code posted above ?

Is there another way of loading the license file which can fix our issue ?


Thanks,

Harshal










Hi Tilal,

We found another method of loading the license only once when the application starts ( by putting this code in global.asax :-

protected void Application_Start(object sender, EventArgs e){

new Aspose.Pdf.License().SetLicense(“Aspose.Pdf.lic”);

new Aspose.BarCode.License().SetLicense(“Aspose.BarCoe.lic”);

}


Would this work if the aspose pdf reference is used up in a web service scenarios where request ?

Essentially our main concern is there shouldn’t be any watermarks on the pdf by using the above code


Thanks,

Harshal


/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;}

<![endif]–>

Hi Harshal,


Thanks for sharing the details.

Please note that Aspose.Pdf initializes the license when first instance/object of Aspose.Pdf for .NET is created and its recommended to place the license initialization code n some static method which is executed once at that start of application. There is no need to re-initialize the license in multi-threaded environment when a new thread is created. The license is valid until the main application thread is running.

May be you can place the license initialization code in Main(), Page_Load() or any method which is executed at the start of application. In case you still face the similar problem or you have any further query, please feel free to contact.

We are sorry for this inconvenience.

Hi @all,


i have the same errormessage. I use a Libary to encapsulate the function.

What can i do in this case? My class isn’t static so: set an static property and set it once?

kind regards
Micha

Hi Micha,


Thanks for contacting support.

The recommended approach is to set license once in an application and it should be initialized before any object of Aspose.Pdf is instantiated. Please avoid making multiple calls to license initialization routine.

Hi,


meanwhile I have found something in documentation:

When to Apply a License

If you are developing a class library, you can call License.SetLicense from a static constructor of your class that uses Aspose.Words. The static constructor will execute before an instance of your class is created making sure Aspose.Words license is properly set.

kind regards
rednose84:
meanwhile I have found something in documentation:

When to Apply a License

If you are developing a class library, you can call License.SetLicense from a static constructor of your class that uses Aspose.Words. The static constructor will execute before an instance of your class is created making sure Aspose.Words license is properly set.
Hi Micha,

The above stated description is related to Aspose.Words API but more or less all the API's have similar license validation mechanism, so you can use same approach to instantiate license for Aspose.Pdf.