Null Reference Exception at BuildItemWithCurrentContext(Object obj)

Topics: Web Client Software Factory
May 10, 2010 at 5:23 AM
Hi, We are using WCSF (February 2008) in our ASP.net Application. After deploying to the production server and test server, Sometimes a page in the application throws a Null Reference Exception. and when this error comes once then ,every page is throwing the same exception. After restarting the IIS (IISRESET) everything works fine. Environment: Windows Server 2008 R2, IIS7 Note: We use windows authentication to log into the application. Also we are using Impersonation with the help of DLLImport["Kernal32.dll"]. The exception is like Server Error in '/' Application. -------------------------------------------------------------------------------- Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [NullReferenceException: Object reference not set to an instance of an object.] Microsoft.Practices.CompositeWeb.WebClientApplication.BuildItemWithCurrentContext(Object obj) +247 Microsoft.Practices.CompositeWeb.Web.UI.Page.OnPreInit(EventArgs e) +62 System.Web.UI.Page.PerformPreInit() +41 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1255 We found an application exception just before this behavior of out application. The log was Log Name: Application Source: Application Error Date: 4/27/2010 1:43:55 PM Event ID: 1000 Task Category: (100) Level: Error Keywords: Classic User: N/A Computer: <computername> Description: Faulting application w3wp.exe, version 7.0.6002.18005, time stamp 0x49e03238, faulting module kernel32.dll, version 6.0.6002.18005, time stamp 0x49e041d1, exception code 0xe053534f, fault offset 0x00000000000176fd, process id 0x%9, application start time 0x%10. Please anybody tell us what could be the actual cause of this behavior
Jun 11, 2010 at 11:49 PM

Hi,

This error has never been reported but based on our understanding, your application might be losing the current HttpContext reference, which causes the crashing. However, it seems to be related with something outside the boundaries of the application. 

Below you can find some information that could help us to clarify this situation:

  1. Verify in the event viewer to see if there is some entry that notify about a possible restarting of the App Pool/w3wp/etc
  2. Does the error occur without Windows AuthN and the impersonate configuration you mentioned?
  3. Have you been able to reproduce the error in a development environment? If your application has UI Automation Tests, it could be helpful if you execute them a couple of times, but with your app working in cassini.
  4. Does the same error occurs when trying to access the app from another machine?
  5. To track where the error occurs, you can add some logging statements to the BuildItemWithCurrentContext method.

We noticed that you’ve posted this question in the IIS forums, so this is something that might help to get it solved.

If you have any other relevant information that can help us to reproduce this problem, please let us know. 

Fernando Antivero
http://blogs.southworks.net/fantivero