我知道this other post,但它似乎不适用于我的情况。
首先,这是我的环境:
Windows XP 64-bit SP3;带有 SP 的 Visual Studio 2008;.NET 3.5 SP1;WPF 应用程序。
我的问题是我似乎无法走到异常发生的地方。它只是继续运行而不是继续调试会话。
这是一些代码——我没有写所有的代码,所以请不要对命名发表评论:)
// start up the WPF application
// set the handler for the Checked event
ToggleButton channelButton1 = new ToggleButton();
channelButton1.Checked += (s, e) =>
ThreadPool.QueueUserWorkItem(SetTcpChannel, 1);
然后在那个SetTcpChannel
方法中:
try
{
int channel = (int)state;
EnsureTcpSocket();
// more logic to do stuff with channel
// that we don't care about for SO
...
}
catch (Exception e)
{
// just for illustration
// this is where I expected the code to return
...
}
最后,在异常实际发生的地方(内部EnsureTcpSocket
):
if (_tcp == null)
{
// this is not a valid ip/port since the
// target machine is not running (test condition)
// but that's ok, I should get some exception
// and continue debugging...right?
_tcp = new TcpClient(ip, port);
}
这是我一直在做的事情:
EnsureTcpSocket
我在里面的行 设置了一个断点SetTcpChannel
,- F11(步入)
EnsureTcpSocket
所以我可以看到_tcp
这段代码 - 尝试 F10 (step-over)
TcpClient
构造函数
在最后一步,应用程序从调试器中恢复并继续运行,我从未看到任何异常。
有任何想法吗?