gpt4 book ai didi

c# - 我应该忽略 WCF 中的第一次机会异常吗?

转载 作者:太空狗 更新时间:2023-10-30 01:19:57 25 4
gpt4 key购买 nike

在 Visual Studio 中运行 WCF 服务,我在调试输出中看到大量异常。

A first chance exception of type 'System.ServiceModel.FaultException' occurred in System.ServiceModel.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.ServiceModel.Channels.dll

它们似乎被无规律地抛出:无论如何我都无法找出任何模式(即从每隔几秒到几十秒)。

如果我将调试设置为在 FaultException 上中断,我看到它们被 System.ServiceModel.Dispatcher.ErrorBehavior.ThrowAndCatch(Exception e, Message message) 抛出.

异常消息是 {“由于 EndpointDispatcher 的 AddressFilter 不匹配,接收方无法处理带有 To '' 的消息。检查发送方和接收方的 EndpointAddresses 是否一致。”

显而易见的答案似乎是“你的地址是空的”。但这发生在任何客户端连接之前。

这只是“正常”,还是我做错了什么的征兆?

最佳答案

快速回答是“是的,您可以忽略第一次机会异常”。它们是实际上已经处理过的异常。因此,它们应该被视为正常的执行工作流。

Visual Studio 会通知开发人员发生的每个异常,即使已处理也是如此。每个异常都会抛出一个“第一次机会异常”,它不会中断正常的调试 session 。如果未处理此第一次机会异常,则调试 session 会被“第二次机会异常”中断。 “first chance exceptions”的值(value)仅针对开发者的洞察力知识。

在此blog post您可以查看有关第一次机会异常的更多详细信息。从引用的帖子中复制:

Does a first chance exception mean there is a problem in my code? First chance exception messages most often do not mean there is a problem in the code. For applications / components which handle exceptions gracefully, first chance exception messages let the developer know that an exceptional situation was encountered and was handled.

希望我有所帮助!

关于c# - 我应该忽略 WCF 中的第一次机会异常吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21156659/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com