Object reference not set to an instance of an object.

G

Guest

Hi
We are using .net 1.1 on windows 2003 server. This is we are facing in our
production server.

When we are doing the load testing we are getting the bellow error. While
the load testing this error is not coming frequently. When we run 20 threads
for 3 mins we are getting this error message 2 or 3 times. But this line of
code is executed by all the threads.
Please any one face this problem earlier kindly tell me how you could solve
the problem. bellow i have given the actual .net code and expline the code.
if you want any more information please let me know i will provide.


==============
Event Type: Error
Event Source: Application
Event Category: None
Event ID: 22
Date: 5/21/2007
Time: 3:43:10 PM
User: N/A
Computer: SGMS-DEV2
Description:
The description for Event ID ( 22 ) in Source ( Application ) cannot be
found. The local computer may not have the necessary registry information or
message DLL files to display messages from a remote computer. You may be able
to use the /AUXSOURCE= flag to retrieve this description; see Help and
Support for details. The following information is part of the event:
,Message:System.DataTesting String:facet ::CREATOR : at
System.Data.DataView.GetRecord(Int32 recordIndex)
at System.Data.DataView.get_RowViewCache()
at System.Data.DataView.GetElement(Int32 index)
at System.Data.DataView.get_Item(Int32 recordIndex)
at SUI.UIs.Index.constTabs()Object reference not set to an instance of an
object.,DateTime :21/05/2007 15:43:10SessionID :j4ychj3uhjohsa452qkdg055.
============

..net code
============
in the bellow code
1. "metaDataElementsDs" this dataset object is referthe Application object.
in the page load event assign the applicoan object in to the local variable.
"metaDataElementsDs = (DataSet) Application["metaDataElementsDs"];"

2. in the bellow code we are getting the exception at the bellow line of code.

"displayLevel = int.Parse(dataView[0]["DisplayLevel"].ToString());"


=============
private int GetLevelForDisplay(string facetName)
{
DataView dataView;
string strFilter=null;
int displayLevel = 0;
try
{
dataView = new DataView();
dataView = metaDataElementsDs.Tables[0].DefaultView;
strFilter= "MDEName='"+facetName.ToUpper().Replace("'","''") +"'";
dataView.RowFilter = strFilter;
if(dataView.Count > 0)
{
displayLevel = int.Parse(dataView[0]["DisplayLevel"].ToString());
}
return displayLevel;
}
catch (Exception err)
{
SUI.Classes.ApplicationLog.WriteToEventLog err.Source + " :" +
err.StackTrace.ToString(), "ERR",22,0,err,Session);
}
finally
{
dataView = null;
}

return displayLevel;
}
 
G

Guest

Ganesan said:
Hi
We are using .net 1.1 on windows 2003 server. This is we are facing in our
production server.

When we are doing the load testing we are getting the bellow error. While
the load testing this error is not coming frequently. When we run 20 threads
for 3 mins we are getting this error message 2 or 3 times. But this line of
code is executed by all the threads.
Please any one face this problem earlier kindly tell me how you could solve
the problem. bellow i have given the actual .net code and expline the code.
if you want any more information please let me know i will provide.


==============
Event Type: Error
Event Source: Application
Event Category: None
Event ID: 22
Date: 5/21/2007
Time: 3:43:10 PM
User: N/A
Computer: SGMS-DEV2
Description:
The description for Event ID ( 22 ) in Source ( Application ) cannot be
found. The local computer may not have the necessary registry information or
message DLL files to display messages from a remote computer. You may be able
to use the /AUXSOURCE= flag to retrieve this description; see Help and
Support for details. The following information is part of the event:
,Message:System.DataTesting String:facet ::CREATOR : at
System.Data.DataView.GetRecord(Int32 recordIndex)
at System.Data.DataView.get_RowViewCache()
at System.Data.DataView.GetElement(Int32 index)
at System.Data.DataView.get_Item(Int32 recordIndex)
at SUI.UIs.Index.constTabs()Object reference not set to an instance of an
object.,DateTime :21/05/2007 15:43:10SessionID :j4ychj3uhjohsa452qkdg055.
============

.net code
============
in the bellow code
1. "metaDataElementsDs" this dataset object is referthe Application object.
in the page load event assign the applicoan object in to the local variable.
"metaDataElementsDs = (DataSet) Application["metaDataElementsDs"];"

2. in the bellow code we are getting the exception at the bellow line of code.

"displayLevel = int.Parse(dataView[0]["DisplayLevel"].ToString());"


=============
private int GetLevelForDisplay(string facetName)
{
DataView dataView;
string strFilter=null;
int displayLevel = 0;
try
{
dataView = new DataView();
dataView = metaDataElementsDs.Tables[0].DefaultView;

Oops. Here you get a reference to the default view of the data table.
That means that all threads will use the same DataView object.
strFilter= "MDEName='"+facetName.ToUpper().Replace("'","''") +"'";
dataView.RowFilter = strFilter;
if(dataView.Count > 0)
{

If, at this exact moment, another thread changes the filter of the
DataView object, the data will no longer be relevant for this thread. If
the view is empty, you will get an exception.
displayLevel = int.Parse(dataView[0]["DisplayLevel"].ToString());
}
return displayLevel;
}
catch (Exception err)
{
SUI.Classes.ApplicationLog.WriteToEventLog err.Source + " :" +
err.StackTrace.ToString(), "ERR",22,0,err,Session);
}
finally
{
dataView = null;
}

return displayLevel;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top