I have a Windows C# application that is trying to invoke a remote WebService
(both mine). My problem is that trying to call the VSNet2005 generated async
methods on the service can throw exceptions that are not caught and returned
to the client.
In the "Reference.cs" file the calls are just simple
/// <remarks/>
public void NewsAsync(string authentication) {
this.NewsAsync(authentication, null);
}
/// <remarks/>
public void NewsAsync(string authentication, object userState) {
if ((this.NewsOperationCompleted == null)) {
this.NewsOperationCompleted = new
System.Threading.SendOrPostCallback(this.OnNewsOpe rationCompleted);
}
this.InvokeAsync("News", new object[] {
authentication}, this.NewsOperationCompleted,
userState);
}
private void OnNewsOperationCompleted(object arg) {
if ((this.NewsCompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEvent Args
invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEve ntArgs)(arg));
this.NewsCompleted(this, new
NewsCompletedEventArgs(invokeArgs.Results, invokeArgs.Error,
invokeArgs.Cancelled, invokeArgs.UserState));
}
}
If something is not right (the service is down for example) I'll get things
like "Socket exceptions" that are thrown and not caught and returned to my
async completedEventHandler.
My client side code is simply
community.NewsCompleted += new
NewsCompletedEventHandler(_community_NewsCompleted );
_community.NewsAsync(authString);
The completed method does get called but only after the exception is thrown
and handled (logged and exit) in my unhandled thread exception handler.
Is this working as I should expect?
Can someone advise on how/where I can catch these exceptions as they are
expected as (from time to time) the service may not be available for some
reason.
I'm using async calls here so that I can perform other UI tasks while
waiting for low important results.
Thanks
--
Neil