Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old May 30th, 2006, 01:34 AM
Registered User
 
Join Date: Nov 2004
Location: Bangalore, Karnataka, India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Unhandled NullReference Exception

Hello people,

I am finding a hard time in resolving the nullreferenceexception my application is throwing.

My application has two forms.
In the first form i am performing the following operations.
1. Fetching values from the database
2. Creating an instance of the second form
3. Making the first form invisible
4. Making the second form visible
5. Navigating to second form by calling a method in which i am
   populating the data fetched from database into a list view control

These are the steps that are executed in my application. Now in the first two runs i am able to display fetched data in the second form and navigate back to the first form through a button_click event where in i am making the second form invisible and making the first form visible(only single instance created for both forms). When i perform the operation for the third run the second form is loaded with data and immediately breaks giving the "
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object."
The stack trace is as follows ---
************************************************** ********************
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)
   at System.Windows.Forms.ComponentManager.System.Windo ws.Forms.UnsafeNativeMethods+IMsoComponentManager. FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.ThreadContext.RunMessageLoopI nner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.ThreadContext.RunMessageLoop( Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at App.SearchCriteria.Main() in D:\App\Search.vb:line 5The program '[3436] App.exe' has exited with code 0 (0x0).
************************************************** ********************

I have checked the control flow and its complete. The control comes back to the event which fired the search on the first form and after it exits this event this exception is thrown. This occurs every third run i perform a search. In the first two runs i am not facing any problem but in the third run i am facing this exception.

Can any one help me in resolving this issue as i am running short of time.

Thanks in advance
dheeraj
Reply With Quote
  #2 (permalink)  
Old May 30th, 2006, 06:55 PM
Authorized User
 
Join Date: May 2006
Location: Chico, CA, USA.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is difficult to debug w/o seeing the code. What you should do is set a break point somewhere near where you suspect the problem lies, and then run the program using the debugger (F5). After the program stops on the breakpoint, trace through (F10) until you reach the bugger line.

Brandon
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
unhandled exception dipakp ASP.NET 2.0 Professional 1 July 6th, 2007 03:16 PM
Null reference exception was unhandled labby C# 2005 0 April 24th, 2007 07:14 AM
Unhandled NullReference Exception MAKO C# 1 April 19th, 2006 06:46 AM
Unhandled Exception stu9820 ASP.NET 1.0 and 1.1 Basics 11 January 14th, 2004 05:55 PM
Unhandled Exception: mbarrett C# 3 August 1st, 2003 06:25 PM



All times are GMT -4. The time now is 12:24 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.