Solved

Getting Exception saying that Object refrence is not set to instance of an Object....

Posted on 2009-05-11
9
159 Views
Last Modified: 2012-05-06
Hi

i am getting this exception when i came to this line in code below... tabManRecon.Controls.Add(ucReconManually);

can any one see what the problem is?
ReconManually ucReconManually;
        private void ShowReconManually()
        {
            if (ucReconManually == null)
            {
                ucReconManually = new ReconManually(myOper);
                tabManRecon.Controls.Add(ucReconManually);
                ucReconManually.Dock = DockStyle.Fill;
                ReconManualTabMenu = ((IMenu)ucReconManually).TabMenu();
            }
            ucReconManually.Show();
        }

Open in new window

0
Comment
Question by:Adnan
  • 6
  • 3
9 Comments
 
LVL 39

Expert Comment

by:abel
ID: 24353344
most likely the tabManRecon is not instantiated. Where is it declared? If you put a breakpoint there, is it null?
0
 
LVL 39

Expert Comment

by:abel
ID: 24353348
> is it null?
i mean: you can see that by hovering over it with your mouse or by typing it in in the Immediate window
0
 

Author Comment

by:Adnan
ID: 24353360
sorry the real exceotion message is error creating window handeling????
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
LVL 39

Expert Comment

by:abel
ID: 24353366
that sounds more like the exception that comes after the previous. Can you place a breakpoint on that line or do you get another exception before that breakpoint? If you receive the exception, can you post the stacktrace here?
0
 
LVL 39

Expert Comment

by:abel
ID: 24353389
This error (cannot create window handle) can be raised as a result of too many (child) windows, or objects that are out of scope but not Disposed and are leaking memory or simply never release there handles. Here's one post on the subject: http://stackoverflow.com/questions/222649/winforms-issue-error-creating-window-handle

This one is on Dispose (a good read and if you never used Dispose before, i recommend reading it) http://blogs.msdn.com/jfoscoding/articles/450835.aspx
0
 

Author Comment

by:Adnan
ID: 24353424
if i set brakpoint on this li9ne " tabManRecon.Controls.Add(ucReconManually);", i do not get exception, i set breakpoint on the line and run my app, when it stop on the brakpoint i clikcked F5 and i dident get the exception....i can see mye form...????
0
 
LVL 39

Accepted Solution

by:
abel earned 500 total points
ID: 24353459
Read this post: http://thedatafarm.com/devlifeblog/archive/2006/02/22/40253.aspx

and definitely read my suggestions in the previous post, most notably the one on Dispose. You seem to have some serious resources problems. Which may be why it does not happen in one case, but it does happen in another case...
0
 

Author Closing Comment

by:Adnan
ID: 31580095
thanks...
0
 
LVL 39

Expert Comment

by:abel
ID: 24353775
you're welcome ;)

-- Abel --
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question