Seth,
The exception is thrown when there is no object allocated for a reference
and you try to dereference it.
For example,
class MyClass1
{
public void MyMethod1() { } // I am returning null
}
class MyClass2
{
public MyClass1 MyMethod2() { return null; } // I am returning
null
}
class Class1
{
[STAThread]
static void Main(string[] args)
{
MyClass2 myClass2 = new MyClass2();
myClass2.MyMethod2().MyMethod1();
// myClass2.MyMethod2()
returns a null. And I dereference it to call MyMethod1() and it will
// throw the exception you
see.
}
}
Typically this happens when you de reference without checking for null
something = Foo.Bar.Car.Execute();
// Very common C# code.
Say Foo is a class and Bar and Car are properties on it.
Now Foo can be null, Foo.Bar can return null, Foo.Bar.Car can return null.
If you execute the above statement without checking if the return values
are null, then you get the NullReference exception.
_Rakesh
--------------------
From: "Seth Broomer" <as**@asdsd.com>
Subject: I get this error intermidently
Date: Mon, 5 Jan 2004 11:18:17 -0800
Lines: 33
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <eC**************@TK2MSFTNGP11.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: ppp-63-204-234-180.adiyh.com 63.204.234.180
Path:
cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTN GP08.phx.gbl!TK2MSFTNGP11.
phx.gblXref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.csharp:209575
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
Can someone please tell me what might be causeing this error. I get it
every once in a while.
I just noticed this also...where it says c:\sethbacup\d...
that is where i do my build. But then i copy over my files to a diffrent
server. Why is that path not shown?
thanks
seth
Error Message: Object reference not set to an instance of an object.
Stack Trace:
at
System.Data.SqlClient.SqlConnectionPoolManager.Re turnPooledConnection(SqlIn
ternalConnection pooledConnection) at
System.Data.SqlClient.SqlConnection.Open() at SBC.util.SBC_DB..ctor() in
c:\sethbackup\d drive\web\fvi\inc\util\sbc_db.cs
:line 26 at FVI.inc.navigation.TopToolBar..ctor() in C:\sethbackup\D
Drive\web\FVI\inc\navigation\TopToolBar.ascx.cs
:line 20 at ASP.TopToolBar_ascx..ctor() in
C:\WINNT\Microsoft.NET\Framework\v1.0.3705\Tempor ary ASP.NET
Files\root\d65a3772\6d86c8d4\9exvzoml.0.cs
:line 35 at ASP.nonReportingFac_aspx.__BuildControltopToolBar( ) in
E:\intranet\FVI\desktop\census\nonReportingFac.as px
:line 17 at ASP.nonReportingFac_aspx.__BuildControlTree(Contro l __ctrl) in
E:\intranet\FVI\desktop\census\nonReportingFac.as px
:line 1 at ASP.nonReportingFac_aspx.FrameworkInitialize() at
System.Web.UI.Page.ProcessRequest() at
System.Web.UI.Page.ProcessRequest(HttpContext context) at
System.Web.CallHandlerExecutionStep.Execute() at
System.Web.HttpApplication.ExecuteStep(IExecution Step step, Boolean&
completedSynchronously)
Rakesh, EFT.
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm