IntelliTrace 捕获的静默异常

发布于 2024-09-28 15:41:25 字数 1110 浏览 0 评论 0原文

下午好,

我在 WCF 和 IntelliTrace 方面遇到了一个奇怪的问题。我有一个应用程序,正在使用 basicHttpBinding 使用本地托管的 WCF 端点(VS2010 中内置的开发服务器)进行测试。应用程序一直正常运行:没有异常进入应用程序,并且所有 WCF 调用都返回数据。

我一高兴,决定看一下 IntelliTrace 输出,并注意到我对 WCF 的第一次调用引发了两个异常:

Exception:Thrown: "No connection could be made because the target machine actively refused it" (System.Net.Sockets.SocketException)
A System.Net.Sockets.SocketException was thrown: "No connection could be made because the target machine actively refused it"
Exception:Caught: "No connection could be made because the target machine actively refused it" (System.Net.Sockets.SocketException)
A System.Net.Sockets.SocketException was caught: "No connection could be made because the target machine actively refused it"

我已将应用程序简化为一个简单的用例:

    ServiceClient client = new ServiceClient();
    string[] output = client.LegacyCheck("username");
    Console.WriteLine(output[0]);
    Console.WriteLine(client.GetData(65));

并且我得到了相同的行为。第二次调用没有与之关联的异常。

我很疑惑。如果连接被拒绝,那么为什么异常没有弥补应用程序的不足呢?为什么两次尝试都失败了却成功了呢?

任何帮助表示赞赏!

Good afternoon,

I am running into a curious problem with WCF and IntelliTrace. I have an application that I'm testing using a locally-hosted WCF endpoint (the development server built into VS2010) using the basicHttpBinding. The application has been running normally: no exceptions are are making their way to the app and all of the WCF calls are returning data.

On a lark, I decided to take a look at the IntelliTrace output and noticed that my first call to WCF throws two exceptiosn:

Exception:Thrown: "No connection could be made because the target machine actively refused it" (System.Net.Sockets.SocketException)
A System.Net.Sockets.SocketException was thrown: "No connection could be made because the target machine actively refused it"
Exception:Caught: "No connection could be made because the target machine actively refused it" (System.Net.Sockets.SocketException)
A System.Net.Sockets.SocketException was caught: "No connection could be made because the target machine actively refused it"

I've reduced the application to a trivial use case:

    ServiceClient client = new ServiceClient();
    string[] output = client.LegacyCheck("username");
    Console.WriteLine(output[0]);
    Console.WriteLine(client.GetData(65));

And I get the same behavior. The second call has no exception associated with it.

I'm very puzzled. If the connection is being refused, then why does the exception not make it up to the application? And why would it success after 2 failed tries?

Any help is appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

荒路情人 2024-10-05 15:41:25

无论如何,我在我的 IronPython/WPF 应用程序中也注意到了这种行为。我最终意识到 Intellitrace 只是向您显示正常操作期间引发和捕获的所有异常,即使它是 BCL 或其他库的一部分。

当然,您只需要担心未处理的异常(在它们中断您的执行之后,您通常会在 IntelliTrace 中看到这些异常作为一长串 Thrown: Caught: Thrown: Caught: ....一直到 Thrown: 这将是最后一行,因为未捕获异常,

我愿意打赌 WCF 代码 try 是一对。首先,捕获 SocketException,然后继续其愉快的方式,如果没有 IntelliTrace,您永远不会看到这一点:)

For what it's worth, I've noticed this behavior too with my IronPython/WPF applications. I've eventually realized that Intellitrace is simply showing you ALL of the exceptions that are raised and caught during normal operation, even if its part of a BCL or other library.

Of course, you only need to worry about unhandled exceptions (after they break your execution, you'll usually see those in IntelliTrace as a long chain of Thrown: Caught: Thrown: Caught: .... all the way down to Thrown: which will be the last line as the exception was not caught.

What I'm willing to bet is that the WCF code try's a couple of things first, catches the SocketExceptions, and then continues on its merry way. You wouldn't ever see this, but for IntelliTrace :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文