Question Application error on exit

yakshasa

New member
Joined
Jun 13, 2006
Messages
3
Location
Los Angeles, California USA
Programming Experience
5-10
:confused:In debug mode, after my application closes I am getting "Invoke or
BeginInvoke cannot be called on a control until the window handle has
been created".

It literally happens after the last form - The MDI parent form that
serves as my application's desktop - closes, right after the
FormClosed event End Sub.

I am not doing any sort of direct thread handling in code that calls
Invoke or BeginInvoke.

In the installed application executable, the message becomes
<ApplicationName> "has encountered an error and needs to close".

I recall glimpsing a KB article - which I have since misplaced -
about Framework 2.0 SP1 having an issue that caused the error to
display when an application otherwise closed without problems.

I'm leaning toward that explanation as I have one machine out of
three that is not getting the error, and the difference seems to be
which frameworks are installed (but all three have Framework 2.0
Service Pack 2).

The error cannot be trapped.

Any suggestions?

XP Machine Without error:

Microsoft .NET Compact Framework 1.0 SP3 Developer

Microsoft .NET Compact Framework 2.0 SP2

Microsoft .NET Compact Framework 3.5

Microsoft .NET Framework 1.1

Microsoft .NET Framework 1.1 Hotfix (KB928366)

Microsoft .NET Framework 2.0 Service Pack 2

Microsoft .NET Framework 3.0 Service Pack 2

Microsoft .NET Framework 3.5 SP1

VISTA Machine with error:

Microsoft .NET Compact Framework 2.0 SP2

Microsoft .NET Compact Framework 3.5

Microsoft .NET Framework 3.5 SP1

XP (SP3) Machine With error:


Microsoft .NET Compact Framework 2.0 SP2

Microsoft .NET Framework 3.0 Service Pack 2

Microsoft .NET Framework 3.5 SP1
 
Maybe you have a background worker still raising events like reporting progress that get handled somewhere. Those handlers in turn try to change the value of a progress bar or some other life sign on a destroyed control. Or maybe it's a timer...

Closing the form does not necessarily kill the application immediately, so the next iteration of the timer or background worker's report event has the time to crash the app before the application closes based on a luck factor.

This is just an educated guess that fits the intermittent crash symptom. I hardly ever met a framework issue that wasn't minor AND well documented and they usually have to do with complex combinations of component usages, not with common use cases like "closing the application"...
 
Back
Top