服务参考客户端错误?
你好,我有一个 WPF 应用程序,它使用对 Web 服务的服务引用...
现在我有一个 GUI 组件来跟踪此进度...
但我似乎在这里有某种错误,它只发生在某些机器上而且不经常.. 我使用 MethodNameAsync 启动调用并显示进度条,直到发生匹配的 Completed 事件。
有时我连续调用 3 个不同的异步方法,但只有其中两个获得 Completed 事件,因此 GUI 将被锁定,并且必须重新启动应用程序。
在完全沮丧的几周后,我发现了事件 AppDomain.CurrentDomain.FirstChanceException,所以我连接到它并开始记录所有 FirstChanceExceptions..
在引发第二个事件之前,出现 System.Net.Sockets.SocketException“提供了无效的参数” ” 被抛出,之后出现 System.ObjectDisposeException “无法访问已处置的对象。”抛出的都是第一次机会异常..
我猜我的wcf客户端在发生这种情况时忘记了第三个方法调用,但我的加载指示器没有..
那么这是一个已知的错误还是我错过了一些东西?
按要求编辑代码:
mCheckInService = New CheckInServiceClient()
AddHandler mCheckInService.GetPersonActivitiesCompleted, AddressOf CheckInService_GetPersonActivitiesCompleted
AddHandler mCheckInService.GetPersonArticlesCompleted, AddressOf CheckInService_GetPersonArticlesCompleted
AddHandler mCheckInService.GetPersonImageCompleted, AddressOf CheckInService_GetPersonImageCompleted
Dim workItem As WorkItem = Context.WorkDisplayService.AddWorkItem(Me, Resources.Label.DownloadingPersomImage)
mCheckInService.GetPersonImageAsync(Context.Session, person, workItem)
workItem = Context.WorkDisplayService.AddWorkItem(Me, "Hämtar aktiviteter")
mCheckInService.GetPersonActivitiesAsync(Context.Session, Person, workItem)
workItem = Context.WorkDisplayService.AddWorkItem(Me, Resources.Label.DownloadingPersonArticles)
mCheckInService.GetPersonArticlesAsync(Context.Session, person, workItem)
Private Sub CheckInService_GetPersonActivitiesCompleted(ByVal sender As Object, ByVal e As GetPersonActivitiesCompletedEventArgs)
Dim workItem As WorkItem = CType(e.UserState, WorkItem)
If (Context.WorkDisplayService.FinishWorkItem(Me, workItem)) Then
Private Sub CheckInService_GetPersonArticlesCompleted(ByVal sender As Object, ByVal e As GetPersonArticlesCompletedEventArgs)
Logger.Trace("CheckInService_GetPersonArticlesCompleted()")
Dim workItem As WorkItem = CType(e.UserState, WorkItem)
If (Context.WorkDisplayService.FinishWorkItem(Me, workItem)) Then
Private Sub CheckInService_GetPersonImageCompleted(ByVal sender As Object, ByVal e As GetPersonImageCompletedEventArgs)
Logger.Trace("CheckInService_GetPersonImageCompleted()")
Dim workItem As WorkItem = CType(e.UserState, WorkItem)
If (Context.WorkDisplayService.FinishWorkItem(Me, workItem)) Then
它的 GetPersonActivitiesAsync 永远不会完成。
编辑:
通过不使用异步方法而是使用将逐一调用它们的线程来修复此临时问题。现在这不是一个优雅的解决方案,我应该能够使用异步方法...
Hi i have a WPF application that uses a service reference to a web service...
Now i have a GUI component that tracks the progress of this...
But i seem to have some sort of bug here, it only occurs on some machines and not often..
I start a call with MethodNameAsync and display the progress bar until the matching Completed event occurs.
some times i call 3 different async methods in a row but only the two of them get their Completed event raised so the GUI will be locked and the application has to be restarted.
After being totally frustrated a few weeks i found the event AppDomain.CurrentDomain.FirstChanceException, so i hooked up to it and started logging all FirstChanceExceptions..
Before the second event is raised a System.Net.Sockets.SocketException "An invalid argument was supplied" is thrown and after that a System.ObjectDisposedException "Cannot access a disposed object." is thrown both are first chance exceptions..
i guess my wcf client forgets about the third method call when this happens but my loading indicator does not..
So is this a known bug or am i missing some thing?
Edit code as requested:
mCheckInService = New CheckInServiceClient()
AddHandler mCheckInService.GetPersonActivitiesCompleted, AddressOf CheckInService_GetPersonActivitiesCompleted
AddHandler mCheckInService.GetPersonArticlesCompleted, AddressOf CheckInService_GetPersonArticlesCompleted
AddHandler mCheckInService.GetPersonImageCompleted, AddressOf CheckInService_GetPersonImageCompleted
Dim workItem As WorkItem = Context.WorkDisplayService.AddWorkItem(Me, Resources.Label.DownloadingPersomImage)
mCheckInService.GetPersonImageAsync(Context.Session, person, workItem)
workItem = Context.WorkDisplayService.AddWorkItem(Me, "Hämtar aktiviteter")
mCheckInService.GetPersonActivitiesAsync(Context.Session, Person, workItem)
workItem = Context.WorkDisplayService.AddWorkItem(Me, Resources.Label.DownloadingPersonArticles)
mCheckInService.GetPersonArticlesAsync(Context.Session, person, workItem)
Private Sub CheckInService_GetPersonActivitiesCompleted(ByVal sender As Object, ByVal e As GetPersonActivitiesCompletedEventArgs)
Dim workItem As WorkItem = CType(e.UserState, WorkItem)
If (Context.WorkDisplayService.FinishWorkItem(Me, workItem)) Then
Private Sub CheckInService_GetPersonArticlesCompleted(ByVal sender As Object, ByVal e As GetPersonArticlesCompletedEventArgs)
Logger.Trace("CheckInService_GetPersonArticlesCompleted()")
Dim workItem As WorkItem = CType(e.UserState, WorkItem)
If (Context.WorkDisplayService.FinishWorkItem(Me, workItem)) Then
Private Sub CheckInService_GetPersonImageCompleted(ByVal sender As Object, ByVal e As GetPersonImageCompletedEventArgs)
Logger.Trace("CheckInService_GetPersonImageCompleted()")
Dim workItem As WorkItem = CType(e.UserState, WorkItem)
If (Context.WorkDisplayService.FinishWorkItem(Me, workItem)) Then
Its GetPersonActivitiesAsync that never gets completed..
Edit:
Fix this temporary by not using async methods and instead using a thread that will call them one by one.. now this is not a elegant solution, i should be able to use the async methods...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里的线索是“无法访问已处置的对象”。
回调代码有时会发生的情况是,应该侦听回调的代码已被释放,因此当回调返回时,没有人在侦听。
The clue here is "Cannot access a disposed object".
What sometimes happens with callback code is that the code that should be listening for the callback has been disposed, so when the callback comes back, nobody is listening.