AboutSrini Nagarajan Expertise I can answer any kind of questions in ASP.NET, C#, VB.NET, SharePoint 2007, ASP, Coldfusion, Powerbuilder 7.00 / 8.00, JAVA servlets, MS SQL 2000 / MSSQL7, Sybase
Experience Contact me if you need any custom development on ASP.NET, ASP, SharePoint 2007, Coldfusion, Powerbuilder.
Question I have an application in ASP.Net that returns error "Object reference not set to an instance of an object." only if there are more than one visitors.
If i try to open page when there is no one online it does not return this error, if in same time i try to open this page from two computers, then it will return this error.
Line of the error is not always them same, it changes position sometimes it returns that "configuration" object is nothing, sometimes that "template" object is nothing, etc...
In application I do not use multithreading. Application uses SQL server 2005, and i connect using System.Data.SqlClient. Connection is opened on begining of class, and it stays open until class finishes, as there are 10+ queries i need to read, maybe it is important to mention that for all reading i use one DataReader, i open query, read data from DataReader and close it, when new query is on its turn, i use that same DataReader and again open query. And connection is open all the time, until we come to the end of class.
More error details for one of the cases;
Object reference not set to an instance of an object.
at Framework.ConfigurationHandler.GetConfiguration(String& sectionGroupName, String& sectionName, String& itemName)
at Framework.TemplateHandler.PopulateQueries(String& fileName)
at Framework.TemplateHandler.ParseTemplate()
at ASP.default_aspx.__Render__control1(HtmlTextWriter __w, Control parameterContainer)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
at System.Web.UI.Page.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
A bit of trace;
Error Internal connection fatal error.
Internal connection fatal error.
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader()
at Framework.DatabaseHandler.ReadQuery(String& sqlQuery, Int32& cacheQuery, Boolean& forWriting) 0.825020995137356 0.001692
Database Read query "SELECT ID, LangName as label, Description As description, Lower(ShortName) As ShortName FROM tblLanguages WHERE ShowOnHomepage = 1 ORDER BY OrderID". 0.825312852810823 0.000292
Error Connection to SQL server [xxx.xxx.xxx.xx] is not open!
Connection to SQL server [xxx.xxx.xxx.xx] is not open!
at Framework.DatabaseHandler.ReadQuery(String& sqlQuery, Int32& cacheQuery, Boolean& forWriting) 0.82556862428451 0.000256
Sometimes it returns also that Internal connection fatal error, but not always, after a long time debuging, it looks like the object that msot times looses reference and is set to null is database object, second next is configuration object.
Answer Hi
mars - multiple active resultsets might help
MultipleActiveResultSets=True (inside the connection string). This one availble only on sql 2005 and asp.net 2.0
Cehck the following two URL may help you for some more help