c# - VS2010 does not show unhandled exception message in a WinForms Application on a 64-bit version of Windows -



c# - VS2010 does not show unhandled exception message in a WinForms Application on a 64-bit version of Windows -

when create new project, unusual behavior unhandled exceptions. how can reproduce problem:

1) create new windows forms application (c#, .net framework 4, vs2010)

2) add together next code form1_load handler:

int vara = 5, varb = 0; int varc = vara / varb; int vard = 7;

i expect vs breaks , shows unhandled exception message @ sec line. however, happens 3rd line skipped without message , application keeps running.

i don't have problem existing c# projects. guess new projects created unusual default settings.

does have thought what's wrong project???

i tried checking boxes in debug->exceptions. executions breaks if handle exception in try-catch block; not want. if remember correctly, there column called "unhandled exceptions" or in dialog box, excatly want. in projects there 1 column ("thrown").

this nasty problem induced windows wow64 emulation layer allows 32-bit code run on 64-bit version of windows. swallows exceptions in code triggers load event. preventing debugger seeing , stepping in. apparently hard fix, windows , devdiv groups @ microsoft pointing fingers , forth. devdiv can't it, windows thinks right behavior, mysteriously sounds. problem debugger attached, code bomb usual without one.

project + properties, build tab, alter platform target anycpu. unfortunately disables edit + go on vs versions prior vs2013 , might not possible when have dependency on 32-bit code.

other possible workarounds:

debug + exceptions, tick thrown box clr exceptions. write try/catch in load event handler. use application.setunhandledexceptionmode(unhandledexceptionmode.catchexception) in main() method exception trap in message loop isn't disabled in debug mode. setting makes unhandled exceptions hard debug, threadexception event pretty useless. consider if code belongs in load event handler. rare need it, popular vb6 programmers load big deal. ever need load when interested in actual window size after user preferences , autoscaling applied. else belongs in constructor. update windows 8, doesn't have problem.

a write-up problem available in blog post.

c# visual-studio-2010 exception-handling

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -