Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2009-05-11
9
Medium Priority
?
164 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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
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 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

609 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