Solved

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

Posted on 2009-05-11
9
160 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

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…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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…

737 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