Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello All,

I have developed a web application long time back which is working fine in Windows 2008 server.

now we need to move this application to new servers (new pre-prod and prod servers) and after putting necessary configuration in IIS, we have deployed the application on new pre-prod.

But we are getting below mentioned error -

-----------Error-------------------------------------------------------------------------------
Server Error in '/retailer/eosc' 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.]
   Rocs.Global_asax.subFormGetAdminSatList(String& sDlrSatList) in E:\Synergy\ROCS\ROCS_SourceCode\ROCS\Global.asax.vb:431
   Rocs.Global_asax.Session_Start(Object sender, EventArgs e) in E:\Synergy\ROCS\ROCS_SourceCode\ROCS\Global.asax.vb:260
   System.Web.SessionState.SessionStateModule.CompleteAcquireState() +408
   System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +1295
   System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +114
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +374

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1016

----------------End of Error------------------------------------------------------------------


Please note that the application is in .Net 4.0 and the databases are DB2 and SQL Server 2008

Also the same code is working fine on Dev and old Pre-prod server, not sure why I am getting this error.

Is there any IIS config setting which I am missing?

Please help me ASAP

Thanks,
Ankur Bakliwal
Posted
Updated 16-Oct-13 3:08am
v2
Comments
Kornfeld Eliyahu Peter 16-Oct-13 7:08am    
The error occurs in subFormGetAdminSatList (called from Session_Start in global.asax)...
Can you show us the inners of subFormGetAdminSatList?
Rajeev Jayaram 16-Oct-13 7:29am    
Have you ever come across this error "Object reference..." before?
Kornfeld Eliyahu Peter 16-Oct-13 7:43am    
Of course. Million times.
It's a simple null reference...
Sergey Alexandrovich Kryukov 16-Oct-13 13:16pm    
You didn't show any code sample, so, what's the use of the exception stack dump along?
Instead, you need to learn how to resolve such simple problems by yourself...
—SA
bhupsiii 21-Nov-13 12:58pm    
hi Ankur,
Right now i am facing the same issue,Did u find any solution.Please help me regarding this,this is really killing me.

1 solution

Please see my comment to the question: you did not show the code where the exception with the message "Object reference not set to an instance of an object" is thrown.

Not to worry. This is one of the very easiest cases to detect and fix. It simply means that some member/variable of some reference type is dereferenced by using and of its instance (non-static) members, which requires this member/variable to be non-null, but in fact it appears to be null. Simply execute it under debugger, it will stop the execution where the exception is thrown. Put a break point on that line, restart the application and come to this point again. Evaluate all references involved in next line and see which one is null while it needs to be not null. After you figure this out, fix the code: either make sure the member/variable is properly initialized to a non-null reference, or check it for null and, in case of null, do something else.

Please see also: want to display next record on button click. but got an error in if condition of next record function "object reference not set to an instance of an object"[^].

Sometimes, you cannot do it under debugger, by one or another reason. One really nasty case is when the problem is only manifested if software is built when debug information is not available. In this case, you have to use the harder way. First, you need to make sure that you never block propagation of exceptions by handling them silently (this is a crime of developers against themselves, yet very usual). The you need to catch absolutely all exceptions on the very top stack frame of each thread. You can do it if you handle the exceptions of the type System.Exception. In the handler, you need to log all the exception information, especially the System.Exception.StackTrace:
http://msdn.microsoft.com/en-us/library/system.exception.aspx[^],
http://msdn.microsoft.com/en-us/library/system.exception.stacktrace.aspx[^].

The stack trace is just a string showing the full path of exception propagation from the throw statement to the handler. By reading it, you can always find ends. For logging, it's the best (in most cases) to use the class System.Diagnostics.EventLog:
http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx[^].

Good luck,
—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900