WCF异步调用的主要投掷目标调用异常() [英] WCF async calls throwing Target invocation exception in Main()

查看:157
本文介绍了WCF异步调用的主要投掷目标调用异常()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个WCF客户端,这使得异步调用WCF的服务器。我使用的是.NET 3.5,的WinForms。我原来的方法命名为GetPoints(),我从在Visual Studio 2010中生成调用服务代理使用GetPointsAsync()。

I' developing a WCF client which makes Asynchronous calls to the WCF server. I'm using .NET 3.5 with Winforms. My original method is named GetPoints() and I'm using the GetPointsAsync() from the proxy generated by the visual studio 2010 to call the service.

到目前为止,一切都工作很好,但是当服务器抛出一个错误异常问题就来了。 在main()方法的例外出现 - > Application.Run(新Form1中())作为目标调用异常:(

So far everything was working nicely but the problem comes when the server throws a fault exception. The exception arises in the Main() method --> Application.Run(new Form1()) as "Target invocation exception" :(

我尝试了同步方法和异常正确地出现在它应该,所以这个问题是不是在服务器上。 此外,我一直试图找到的InnerException却是没有。事实上,我甚至不能找到targetInvocationException。 据我了解,除应出现的client_GetPointsCompleted()方法,是不是? 有没有别的东西我应该考虑到? 哪里异常去了?

I tried a synchronous method and the exception arises correctly where it should, so the problem is not in the server. Also I've tried to find the InnerException but there is none. In fact I cannot even find the targetInvocationException. As far as I understand, the exception should arise in the client_GetPointsCompleted() method, isn't it ? Is there something else I should take into account ? Where did the exception go ?

推荐答案

的异常应该在错误的属性 GetPointsCompletedEventArgs 实例传递给 client_GetPointsCompleted 事件处理程序。

The exception should be in the Error property of the GetPointsCompletedEventArgs instance passed to the client_GetPointsCompleted event handler.

这篇关于WCF异步调用的主要投掷目标调用异常()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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