Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to Set Next Statement from catch in a Visual Studio on a 64 bit OS

We recently moved to a 64 bit OS (Windows 7) and installed visual studio 2008. Now while debugging once an exception is caught, I am not able to set the next statement back to a code in the try block. I googled about this and hit with this article.

http://blogs.msdn.com/b/dougste/archive/2007/03/21/unable-to-set-next-statement-when-debugging-a-64-bit-debuggee-in-visual-studio-2005-sometimes.aspx

That explains it but This is dated back in 2007. Is there any solution or a work around now?

like image 494
franklins Avatar asked Jan 19 '11 21:01

franklins


2 Answers

.NET uses the underlying plumbing of Windows' structured exception handling. There's a Big Difference in the way x64 exception handling is implemented. It uses tables of addresses, generated by the compiler to locate the proper exception filter. x86 uses a linked list of function pointers, much easier to implement by a compiler.

One of the reasons the x64 way was changed was for security reasons, viral code managed to inject itself by patching the linked list and causing an exception, allowing its payload to execute. There were counter-measures against that in XP SP1, at a cost of efficiency. The x64 redesign avoids that cost.

Well, you can see where that's heading. You ought to debug code with the Platform Target set to x86 anyway. This also enables Edit + Continue, a very valuable debugging aid. It is the default setting for VS2010 projects. Only flip to AnyCPU for the Release build.

like image 135
Hans Passant Avatar answered Nov 15 '22 08:11

Hans Passant


Crazy answer: put only an assigment to variable in the catch and an if/process below it.

like image 39
Joshua Avatar answered Nov 15 '22 06:11

Joshua