开发者

Get more error detail info from WCF in Silverlight client

In Silverlight client I get error but it always looks like :

An exception occurred during the operation, making the result invalid. Check InnerException for exception details.

at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary() at SecretaryAppNav.ClientService.GetChildAndOpiekunByFirstnameLastnameCompletedEventArgs.get_Result() at SecretaryAppNav.Views.FindChild.Client_GetChildAndOpiekunByFirstnameLastnameCompleted(Object sender, GetChildAndOpiekunByFirstnameLastnameCompletedEventArgs e) at SecretaryAppNav.ClientService.Service1Client.OnGetChildAndOpiekunByFirstnameLastnameCompleted(Object state)

In client files I always use try catch to catch erorrs but it never invoke, :

        void Client_GetChildAndOpiekunByFirstnameLastnameCompleted(object sender, GetChildAndOpiekunByFirstnameLastnameCompletedEventArgs e)
    {
        try
        {
            this.dataForm1.ItemsSource = e.Result.Collection;
        }
        catch (FaultException ex)
        {
            System.Windows.Browser.HtmlPage.Window.Alert(ex.Reason.ToString() +  ex.Code.ToString() );
            throw new FaultException(ex.Reason, ex.Code, "开发者_StackOverflowKlikanie");
        }
    }

Should I put this catch in my service files to catch SOAP errors ? Without more info I always searching for mistake in my code like in the dark ... :/


If you're debugging your application and you want to simply catch every exception, you do this:

catch (Exception ex)
{
    System.Windows.Browser.HtmlPage.Window.Alert(ex.Reason.ToString())
}

You may want to re-throw the exception after that or check to see what type of exception it is, but this can be a useful way to catch exceptions in Debug mode.

You also might put a break point on the line of code that catches the general exception. This will allow you to "watch" the exception when it is thrown and then look at its nested inner exception(s).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜