Home Unexpected Null Reference Exception by IIS Server
Reply: 0

Unexpected Null Reference Exception by IIS Server

user1750
1#
user1750 Published in May 23, 2018, 10:41 pm

System.NullReferenceException: Object reference not set to an instance of an object occurred in our routines while using below code snippet:

Public Shared Function AsposePDFLLicense() As Aspose.Pdf.License
Dim pdfLicense As Aspose.Pdf.License = New Aspose.Pdf.License
Try
pdfLicense.Embedded = True
pdfLicense.SetLicense(“Aspose.Total.lic”)
Catch lx As Exception
System.Diagnostics.Trace.WriteLine(String.Format("{0}: {1} - {2} ", 
Now.ToString(UtilityToolkit.Sys.TraceTimeFormat), 
System.Reflection.MethodInfo.GetCurrentMethod.Name, lx.ToString))
End Try
Return pdfLicense
End Function

The potential reason for this problem can be that the variable pdfLicense is declared but not initialized.

To emphasize: the code has not changed, the DLL has not changed, the IIS server has not changed, the license file has not changed.

Moreover, the issue had disappeared when I restarted the IIS APP Pool. I want to trace root cause of this issue to avoid it in future.

Why did the problem occur, it never occurred before and now it has popped up out of no where. Below code snippet reproduces the issue:

    Dim pdfLicense As Aspose.Pdf.License = New Aspose.Pdf.License
    pdfLicense = Nothing
    Try
        pdfLicense.Embedded = True
        pdfLicense.SetLicense("Aspose.Total.lic")
    Catch lx As Exception
        Console.WriteLine(String.Format("{0}: {1} - {2} ", Now.ToString(), System.Reflection.MethodInfo.GetCurrentMethod.Name, lx.ToString))
    End Try

I am wondering why could be a null value was assigned to this variable, that resulted in this exception. What IIS routine, like a recycler can be responsible for this behavior?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.310902 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO