Object reference not set to an instance of an object error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I'm using C#. NET to write my programs.
Once in a while i'm receiving the error "Object reference not set to an
instance of an object" in my programs, but i can't reproduce it.
I know the meaning of the error, but because the error seems random and when
i try to recreate it with the same data, the program works fine, i'm out of
ideas to fix the problem.

Can anyone can help.
 
cwb said:
I'm using C#. NET to write my programs.
Once in a while i'm receiving the error "Object reference not set to an
instance of an object" in my programs, but i can't reproduce it.
I know the meaning of the error, but because the error seems random and when
i try to recreate it with the same data, the program works fine, i'm out of
ideas to fix the problem.

That probably means you're trying to dereference a null (Nothing in
VB.NET) reference, e.g.

string x = null;
int i = x.Length; // Bang!

Look at the stack trace when you get the exception and it's likely to
make things clear.
 
Thanks for your reply....

Sadly the stack trace wasn't of any help. It gave me the method in the
program,
but when i try to debug, everything looks fine.
I was thinking, maybe the network speed or collisions may be the cause of my
problems.
I'm gonna look in the VB.NET ref.

Thanks again
 
Back
Top