Re: Object reference not set to an instance of an object

From: Marcos Stefanakopolus (taruntius_at_hotmail.com)
Date: 03/09/05


Date: Wed, 9 Mar 2005 11:04:06 -0800

The error is almost certainly in your code, not in any of those DLLs. I
would bet money that somewhere you have a variable that is declared to be of
some reference type, but you never assigned it to a "new" object of that
type. E.G:

ArrayList foo;
foo.Add("hi there");

This will generate that same error, whereas:

ArrayList foo;
foo = new ArrayList();
foo.Add("hi there");

will work fine. I most often trip myself up this way when I've got a
non-static field in a class that is of some reference type, but I forget to
initialize it in the constructor. That's about the only situation I ever
run into where it even makes sense to separate the declaration of the
variable from the initialization anyway. In your case, if you really think
the exception is originating from within one of those DLLs, then you're
probably passing an uninitialized object into some library routine, and are
triggering the exception that way.

"Steve Teeples" <SteveTeeples@discussions.microsoft.com> wrote in message
news:27D10CF1-34BF-4875-8407-102DDEDFB119@microsoft.com...
>I keep getting the error "Object reference not set to an instance of an
> object." The unhandled exception is a System.NullReferenceException. It
> is
> occurring in an "unknown module". How do I load within the IDE debug
> symbols
> for system.dll, drawing.dll, forms.dll to trace this error?
> --
> Steve



Relevant Pages

  • Re: Operation can be dispatching in only one type
    ... its physical existence is allowed start just before actual ... declaration, but its existence is somewhat sleepy, a larva, not yet the ... overriding procedure Initialize; ... Then, with exception contracts, if you declared the ...
    (comp.lang.ada)
  • Re: getting back to null range
    ... The declaration of A produces a warning, because it is read but never ... anon got an exception without pragma Suppress because in his case A ... So the exception is appropriate. ... So what does he prove with an erroneous program? ...
    (comp.lang.ada)
  • Re: AfxBeginthread exception
    ... You should be very careful to NEVER manipulate a control from a thread; ... therefore, if this thread is writing to the edit control, your design is questionable. ... But without the declaration of the function, you have essentially said "my program doesn't ... build or release build) my application crashes(exception to access ...
    (microsoft.public.vc.mfc)
  • Re: SafeArrayTypeMismatchException
    ... There is a function in one of my dlls whose signature is as follows: ... Declaration for my Function is as follows: ... As Integer, ByVal Z As String, AAs String, AAs Integer) As ... ReDim la_accessAs Integer ...
    (microsoft.public.dotnet.languages.csharp)
  • weird problem with XMLSerializer
    ... I have an application with a bunch of DLLs that are loaded in as plugins. ... 'Break Into Debugger' then no exception is raised at all but the code skips ... Public Class Test ... Public Sub New ...
    (microsoft.public.dotnet.languages.vb)

Loading