Solved

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

Posted on 2009-05-11
9
157 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
Comment Utility
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
Comment Utility
> 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
Comment Utility
sorry the real exceotion message is error creating window handeling????
0
 
LVL 39

Expert Comment

by:abel
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 39

Expert Comment

by:abel
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
thanks...
0
 
LVL 39

Expert Comment

by:abel
Comment Utility
you're welcome ;)

-- Abel --
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now