Link to home
Create AccountLog in
Avatar of Adnan
AdnanFlag for Norway

asked on

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

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

Avatar of abel
abel
Flag of Netherlands image

most likely the tabManRecon is not instantiated. Where is it declared? If you put a breakpoint there, is it null?
> 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
Avatar of Adnan

ASKER

sorry the real exceotion message is error creating window handeling????
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?
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
Avatar of Adnan

ASKER

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...????
ASKER CERTIFIED SOLUTION
Avatar of abel
abel
Flag of Netherlands image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Adnan

ASKER

thanks...
you're welcome ;)

-- Abel --