Visual Studio 2008/2010 SP1,如何跳出一个catch? [英] Visual Studio 2008/2010 SP1, how to jump back out of a catch?

查看:120
本文介绍了Visual Studio 2008/2010 SP1,如何跳出一个catch?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用调试器(vs2008)。

I am using the debugger (vs2008).

一旦我进入了一个catch语句,我想知道是否有任何方法将执行光标设置为try的开始。

Once I've stepped into a catch statement, I would like to know if there is any way to set the execution cursor back to the beginning of the try.

只是拖动它似乎不起作用,是否有一些设置需要更改?

Just dragging it there doesn't seem to work, is there some setting I need to change?

例如:

try 
{
    //Want the cursor back here
}
catch
{
    //some code, cursor is here...
}


推荐答案

显然,这取决于您使用的是哪种风格的.NET运行时。当我第一次写这篇文章的时候,当我尝试它时,它对我来说很好,但我正在使用我的工作电脑,安装了一个32位操作系统。

Apparently it depends which flavor of .NET runtime you are using. At the time I first wrote this, it worked fine for me when I tried it, but I was using my work PC, with a 32-bit OS installed.

我'使用这个代码片段来测试:

I'm using this code snippet to test:

try
{
    throw new Exception();
}
catch
{
    Console.WriteLine("Error");  // Breakpoint here
}

您不能在 try line。它将在紧跟其后的行上(打开块声明)。

You can't set the cursor on the try line. It will be on the line following immediately after it (the opening of the block statement).

将光标拖动到该行或 try 线程为我编译我的.NET程序为x86工作正常。如果您正在运行一个32位操作系统,它也可以工作。但是,当您使用64位环境并编译任何CPU x64 时,您将收到以下错误消息:

Dragging the cursor to that line or the try line works fine for me when I compile my .NET program for x86. It will also work if you're running a 32-bit OS. However, when you're on a 64-bit environment and compile for Any CPU or x64, you will get the following error message:

由于这仅用于调试,您可能需要为x86进行编译,因此将使用32位运行时。转到构建菜单,然后选择配置管理器。在平台下,如果目前不在列表中,请选择 x86 新建... 。在后一种情况下,您将得到一个新的对话框。选择如下所示的选项,然后单击确定:

Since this is for debugging purposes only, a possible workaround for you would be to compile for x86, so the 32-bit runtime will be used. Go to the Build menu and choose Configuration Manager. Under Platform, select x86 or New... if it's not currently in the list. In the latter case, you'll get a new dialog. Pick the options as shown below and click OK:

这篇关于Visual Studio 2008/2010 SP1,如何跳出一个catch?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆