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(strin g authentication) {
this.NewsAsync( authentication, null);
}
/// <remarks/>
public void NewsAsync(strin g authentication, object userState) {
if ((this.NewsOper ationCompleted == null)) {
this.NewsOperat ionCompleted = new
System.Threadin g.SendOrPostCal lback(this.OnNe wsOperationComp leted);
}
this.InvokeAsyn c("News", new object[] {
authentication} , this.NewsOperat ionCompleted,
userState);
}
private void OnNewsOperation Completed(objec t arg) {
if ((this.NewsComp leted != null)) {
System.Web.Serv ices.Protocols. InvokeCompleted EventArgs
invokeArgs = ((System.Web.Se rvices.Protocol s.InvokeComplet edEventArgs)(ar g));
this.NewsComple ted(this, new
NewsCompletedEv entArgs(invokeA rgs.Results, invokeArgs.Erro r,
invokeArgs.Canc elled, invokeArgs.User State));
}
}
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 completedEventH andler.
My client side code is simply
community.NewsC ompleted += new
NewsCompletedEv entHandler(_com munity_NewsComp leted);
_community.News Async(authStrin g);
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
(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(strin g authentication) {
this.NewsAsync( authentication, null);
}
/// <remarks/>
public void NewsAsync(strin g authentication, object userState) {
if ((this.NewsOper ationCompleted == null)) {
this.NewsOperat ionCompleted = new
System.Threadin g.SendOrPostCal lback(this.OnNe wsOperationComp leted);
}
this.InvokeAsyn c("News", new object[] {
authentication} , this.NewsOperat ionCompleted,
userState);
}
private void OnNewsOperation Completed(objec t arg) {
if ((this.NewsComp leted != null)) {
System.Web.Serv ices.Protocols. InvokeCompleted EventArgs
invokeArgs = ((System.Web.Se rvices.Protocol s.InvokeComplet edEventArgs)(ar g));
this.NewsComple ted(this, new
NewsCompletedEv entArgs(invokeA rgs.Results, invokeArgs.Erro r,
invokeArgs.Canc elled, invokeArgs.User State));
}
}
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 completedEventH andler.
My client side code is simply
community.NewsC ompleted += new
NewsCompletedEv entHandler(_com munity_NewsComp leted);
_community.News Async(authStrin g);
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
Comment