473,385 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Object reference not set to an instance of an object error

cwb
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.

Nov 22 '05 #1
2 2592
cwb <cw*@discussions.microsoft.com> wrote:
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #2
cwb
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

"Jon Skeet [C# MVP]" wrote:
cwb <cw*@discussions.microsoft.com> wrote:
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Pkpatel | last post by:
Hi, I keep getting this error every time I try to load crystalreportviewer on a webform with a dataset. Here is the error: -------------------------------------------------------- Server...
15
by: Carlos Lozano | last post by:
Hi, What is the right way to create an OCX COM component. The component is already registerred, but can't create an instance. I am using the reference to the interop module created. If I use...
6
by: blash | last post by:
Can someone help me? I really don't have a clue. My company staff told me they often got such error: "Object reference not set to an instance of an object." when they are in search result page...
3
by: nemo | last post by:
Hi, My application works fine on the localhost but spits this error as soon as I put it on the server. I know this error occurs when an object has not been instantiated prior to a reference, but...
3
by: Adam | last post by:
We have a web site that uses .vb for the web pages and .cs for a class module. We are getting the error in .NET 2.0 and VS 2005 beta 2. It does work with .NET 1.1. When trying to access a page...
7
by: Brett | last post by:
I'm not sure why I keep getting this error, "Object reference not set to an instance of an object". Private Function somefunction() as string Dim MyCurrentClass As New Class1 Try For i As...
4
by: Luke Matuszewski | last post by:
Here are some questions that i am interested about and wanted to here an explanation/discussion: 1. (general) Is the objectness in JavaScript was supported from the very first version of it (in...
0
by: cnSoftware | last post by:
I come across this problem during my recent project and even now I am still be puzzled by it. So I paste the procedure here. I wish you can figure out where I am wrong or missing. The sample...
12
by: Andrew Poulos | last post by:
With the following code I can't understand why this.num keeps incrementing each time I create a new instance of Foo. For each instance I'm expecting this.num to alert as 1 but keeps incrementing. ...
2
by: Ralph | last post by:
Hi I don't understand why it's not working: function schedule(imTop){ this.tdImagesTop = imTop; } schedule.prototype.selectEl = function() { alert(this.tdImagesTop);
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.