Solved

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

Posted on 2009-05-11
9
158 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
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 video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

785 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