Free Support Forum - aspose.com

Aspose.Words.License.SetLicense

Hi,

We are getting exception as given below while running a performance test of 20vusers for 20 min. Can you please let us know what would be the reason for this error and what is the solution to this.

Thanks

Subbu

Exception: System.NullReferenceException
Message: Object reference not set to an instance of an object.
Source: Aspose.Words
at ?.?.?(Stream ?)
at ?.?.?(String ?, Assembly ?)
at Aspose.Words.License.SetLicense(String licenseName)
at MyApplication.SystemFrameworks.PrintTool.PrintAsWord.Render(XmlDocument ObjAssessmentXML)
at MyApplication.SystemFrameworks.PrintTool.PrintAsWord.RenderSubmittedAssessment1(MyApplicationRequest ObjMyApplicationRequest, PrintSettingDTO ObjPrintSetting, XmlDocument ObjAssessmentXML, LearningObjectiveDTOCollection ObjLearningObjectiveDTOCollection, Hashtable ObjOtherPrintableInfo)
at MyApplication.Web.frmPrintTool.ibtnOk_Click(Object sender, ImageClickEventArgs e)
at System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e)
at System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain()

I can see that SetLicense method is called for every user request. That is not good. Try moving license activation code to Application_Start handler in Global.asax and see if it helps.

Best regards,

I provided the following code on Global.asax but its not working (Means i am getting that evaluation message and chunk in my documents). So please guide me to achieve this functionality.

Thanks in advance,

I.Prabhaharan.

Please verify that the license setting actually occur when your code is executing. To do this, put a breakpoint on License.SetLicense instruction and run your application in debug mode. The best way of ensuring that SetLicense instruction will be executed in your project before any other action is putting it in the main form constructor for WinForms application or in the application startup handler in Global.asax file for Web application.

Best regards,

Actually i am using the aspose component on SystemFramework. Which is referred by web application. As u suggested i dont want to setlicense each and every hit. So please guide me on this.

Regards,

I.Prabhaharan.

miklovan:

Please verify that the license setting actually occur when your code is executing. To do this, put a breakpoint on License.SetLicense instruction and run your application in debug mode.

Have you tried the above ?

Hi,

I found code as given below works fine.

Note that this code should exist in the assembly at which the Aspose.Words.Document class is instantiated

Namespace PrintTool

Public Class WordLicenseSet
Shared license As Aspose.Words.License = New Aspose.Words.License
Public Shared Sub SetLicense()
license.SetLicense("Aspose.Total.lic")
End Sub
End Class

End Namespace

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the application is started
SystemFrameworks.PrintTool.WordLicenseSet.SetLicense()
End Sub