尝试捕捉 - 没抓

2023-09-06 09:08:39 作者:夜闯你房间

下面是我的问题。我已经使用了几个Web客户端中间件的Web服务。 Web服务是一个包装服务,使调用多个供应商的网络服务。对供应商的网络服务的调用包装在TryCatch而产生不被抓住我的web服务的任何异常,他们陷入了客户端应用程序。

Here's my problem. I have a middleware web service used by several web clients. The web service is a wrapper service that makes calls to several vendors' web services. The call to the vendor's web service is wrapped in a TryCatch but any exceptions generated aren't getting caught by my web service, they're getting caught in the client apps.

我缺少的东西?这是与此相关的posting?

Am I missing something? Is this related to this posting?

下面是一个简单的code片断:

Here's a simplified code snippet:

    Dim VendorWebservice as New VendorWebservice
    Dim VendorResponse As VendorResponse = Nothing
    Dim ClientResponse as New CustomClientResponse
    Try
        VendorResponse = VendorWebservice.VendorWebMethod
    Catch ex As Exception
        ClientResponse.ErrorMessage = ex.Message
        ClientResponse.Status = "VendorError"
        Return ClientResponse
    End Try

修改

要扩大在一些细节......在code成功运行99 +%的时间。在罕见的occaision,有一些问题,与供应商的网站是当这个问题出现。我已经打开VS为一体的Web客户端和Web服务,可以通过code步骤从客户机到WS和背部。当我能够重现问题,我通过客户端code已经走到哪儿它调用我们的Web服务,然后切换到WS code和单步调试,直到它调用厂商的code和在该点,它跳跃返回给客户端code,没有击中Catch块或code后。

To expand upon some of the details... The code runs successfully 99+% of the time. On the rare occaision that there is some issue with the vendor's web site is when this issue is occurring. I've had VS opened for both one of the web clients and the web service and can step through the code from the client to the WS and back. When I can reproduce the issue, I have stepped through the client code to where it calls our web service, then switch to the WS code and step through until it calls the vendor's code and at that point, it jumps back to the client code, without hitting the Catch block or any code after it.

希望有所帮助。

修改

有的贴出的答案提供了途径研究,大多数notibly,有未从System.Exception派生可以创建例外。 (谁知道?),但我也发现,从.NET 2.0及更高版本,这些非System.Exceptions越来越在System.Exception的包裹.NET。因此,从理论上讲,应该排除非System.Exceptions了。

Some of the posted answers have provided avenues to research, most notibly that there are exceptions that can be created that are not derived from System.Exception. (Who knew?) But I also found out that from .NET 2.0 and later, these non-System.Exceptions are getting wrapped by .NET in a System.Exception. So in theory that should rule non-System.Exceptions out.

此外,从我的阅读,调用Web服务时(像我的网络服务是做)理论上只有两种类型的异常应该曾经真的可以看出,System.Net.WebException和System.Web.Services.Protocols.SoapException,这两者派生从System.Exception。我不知道这是否是真的,如果只有2种调用Web服务时可能例外,但我会扔在那里。 :)

Additionally, from my reading, when calling a web service (like my web service is doing) theoretically only two types of exceptions should ever really be seen, System.Net.WebException and System.Web.Services.Protocols.SoapException, both of which derive from System.Exception. I don't know if it is really true if there are only 2 types of exceptions possible when calling a web service, but I'll throw it out there. :)

仍在寻找答案...

修改

再现错误状态已被证明是难以实现的。我已经扔在了code每一个场景回应的预期,被夹在catch块中的错误。虽然理论上.NET应该是包装不从System.Exception派生的异常,唯一合乎逻辑的答案似乎同意乔的回答,我们已经经历了异常不从System.Exception派生,并因此被视为未处理例外。

Reproducing the error condition has proved to be elusive. Every scenario that I've thrown at the code has responded as expected, with the error being caught in the Catch block. While in theory .NET is supposed to be wrapping exceptions that do not derive from System.Exception, the only logical answer appears to agree with Joe's answer that the exception we have experienced does NOT derive from System.Exception and thus is treated as an unhandled exception.

推荐答案

是抛出异常源自异常? (是'异常'肯定是指'System.Exception的')

Are the exceptions being thrown derived from Exception? (Does 'Exception' definitely refer to 'System.Exception')

相关推荐