Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2006

Tip: Looking for answers? Try searching our database.

Application.SetUnhandledExceptionMode()

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Grant Morgan - 28 Jul 2006 03:13 GMT
Hi

I'm relatively competent at windows forms programming in net 2.0 (VS 2005),
however, I've never really gotten my hands dirty with exception handling
until now...

My application is using a startup form (not a sub main) for a windows forms
project, with application framework enabled.

I have found the MyApplication_UnhandledException event, and have used this
to report on any unhandled exceptions. However, it only works if I run the
application in Release mode (ie. not debug mode) and without the VSHost
process (ie. running it outside of VS 2005).

I've been told the way around this is to set the
Application.SetUnhandledExceptionMode - can I only do this from a Sub Main
startup, or can I somehow use the MyApplication_Startup event?

Sorry if my description is all over the place - my brain is a bit "googled"
after reading up on exception handling....

Cheers
Grant
Linda Liu [MSFT] - 28 Jul 2006 14:22 GMT
Hi Grant,

Thanks for your support for Microsoft and VS 2005.

In VB.NET, when an applicatin encounters an unhandled exception, it raises
the UnhandledException event. However, the Visual Basic compiler prevents
applications that are built for debugging from raising this event, to allow
a debugger to handle the unhandled exceptions. This means that if you are
testing your application by running it under the VS IDE debugger, your
UnhandledException event handler will not be called.

This behavior has nothing to do with the
Application.SetUnhandledExceptionMode method.

What's more,  Application.SetUnhandledExceptionMode method must be called
before you instantiate  the main form of your application. That's to say,
if you are going to call this method, you must call it in a Sub Main
startup and before the Applicaiton.Run code(you couldn't call this method
in the Application's Startup event handler). However, it means that you
have to disable application framework and select Sub Main as the Startup
object, which conflicts with the Visual Basic Application Model that
UnhandledException event requires.

Hope this helps.
If you have any concerns, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.