CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Forum has moved

New location: CSLA .NET forum


CSLA .NET Resources:
  • CSLA .NET forum
  • CSLA .NET home page
  • Errors From Data Portal are all generic Async Error

    rated by 0 users
    Answered (Verified) This post has 1 verified answer | 8 Replies | 1 Follower

    Top 100 Contributor
    80 Posts
    Todd Haehn posted on Thu, Mar 20 2014 4:14 PM

    Hi,

    Before upgrading from 4 to 4.5, exceptions coming back from the data portal would have the message of the original exception such as "Another user has modified the row in Table1, update failed".  Now all that comes back as the message is than an Async Error occurred.  There is no detail as to the problem.  What is the method that people are using to return the

    Answered (Verified) Verified Answer

    Top 10 Contributor
    9,475 Posts
    Verified by Andy

    Not a bug, a feature :)

    It turns out that when you await a method that numerous things could occur within that method - even in parallel - and so it is possible for multiple exceptions to be returned.

    The only correct way to return exceptions from an async method is with an async exception - which is really a collection of exceptions that may have been raised by the various tasks that ran in the method.

    In simple code (most code) this will be a collection of one element - which is the actual exception you are looking for.

    Rocky

    All Replies

    Top 10 Contributor
    2,279 Posts
    JonnyBee replied on Fri, Mar 21 2014 10:51 AM

    Hi,

    Look at the inner exception.

    Jonny Bekkum, Norway CslaContrib Coordinator

    Top 100 Contributor
    80 Posts

    I have done that.  there isn't any.  My error dialog recurses through the exceptions to get the innermost one.

    Top 100 Contributor
    80 Posts

    The exception is coming back to the data portal:

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><UpdateResponse xmlns="http://ws.lhotka.net/WcfDataPortal"><UpdateResult xmlns:a="http://schemas.datacontract.org/2004/07/Csla.Server.Hosts.Mobile" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><a:ErrorData><a:ExceptionTypeName>System.AggregateException</a:ExceptionTypeName><a:InnerError><a:ExceptionTypeName>Csla.DataPortalException</a:ExceptionTypeName><a:InnerError><a:ExceptionTypeName>Csla.Reflection.CallMethodException</a:ExceptionTypeName><a:InnerError><a:ExceptionTypeName>System.InvalidCastException</a:ExceptionTypeName><a:InnerError i:nil="true"/><a:Message>Specified cast is not valid.</a:Message><a:Source>System.Data</a:Source><a:StackTrace …

    My code is capturing the error on the client and rethrowing it:

                    DateTime start = DateTime.Now;

                    TransferMonitorGetTransferSetCommand.BeginExecute(Model.Dc.Id, Model.TransferFrom, Model.TransferTo, (o, e) =>

                    {

                        if (e.Error != null)

                        {

                            throw e.Error;

                        }

                        else

                        {

                            Model.UpdateResults(e.Object.TransferSetList);

                            TimeSpan runTime = DateTime.Now - start;

                            UpdateStatus(string.Format("Selected {0:N0} rows In {1} minutes {2}.{3} seconds", Model.TransferSetList.Count, runTime.ToString("%m"), runTime.ToString("%s"), runTime.ToString("%f")), false);

                        }

                    });

    But the inner exception is NULL and e.Error.Message is "One or more errors occurred." The stack trace is only SystemRuntime.ComplierServices.AsyncServices(ThrowAsync>b_O(Object state). 

    Todd

     

    Top 100 Contributor
    80 Posts

    The original exception is being returned back to the client as shown in this captured message:

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><UpdateResponse xmlns="http://ws.lhotka.net/WcfDataPortal"><UpdateResult xmlns:a="http://schemas.datacontract.org/2004/07/Csla.Server.Hosts.Mobile" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><a:ErrorData><a:ExceptionTypeName>System.AggregateException</a:ExceptionTypeName><a:InnerError><a:ExceptionTypeName>Csla.DataPortalException</a:ExceptionTypeName><a:InnerError><a:ExceptionTypeName>Csla.Reflection.CallMethodException</a:ExceptionTypeName><a:InnerError><a:ExceptionTypeName>System.InvalidCastException</a:ExceptionTypeName><a:InnerError i:nil="true"/><a:Message>Unable to cast object of type 'System.DateTime' to type 'System.String'.</a:Message><a:Source>System.Data</a:Source><a:StackTrace>   at System.Data.SqlClient.SqlBuffer.get_String()&#xD…

     

    But the error that is coming back in the code:

                UpdateStatus("Generating Commercial Invoice", true);

                TransferMonitorCommercialInvoiceCommand.BeginExecute(

                    Model.Id,

                    (o, e) =>

                        {

                            if (e.Error != null)

                            {

                                UpdateStatus(string.Empty, false);

                                throw e.Error;

                            }

                            else

                            {

                                Workbook workbook = new Workbook();

                                Worksheet worksheet = workbook.Worksheets.Add();

                              

                             }

                        });

     

    Is this:

    “One or more errors occurred.” With a stack trace of System.Runtime.CompilerServices.AsyncServices.<ThrowAsync>b__0(Object state).

    The inner exception is NULL.

    Todd

    Top 100 Contributor
    80 Posts

    This appears to be a bug in CSLA's async implementation.  It worked fine in CSLA 4.

    Todd

    Top 10 Contributor
    9,475 Posts
    Verified by Andy

    Not a bug, a feature :)

    It turns out that when you await a method that numerous things could occur within that method - even in parallel - and so it is possible for multiple exceptions to be returned.

    The only correct way to return exceptions from an async method is with an async exception - which is really a collection of exceptions that may have been raised by the various tasks that ran in the method.

    In simple code (most code) this will be a collection of one element - which is the actual exception you are looking for.

    Rocky

    Top 100 Contributor
    80 Posts

    Rocky,

    Do you have an example I could use?  I am mostly interested in errors returned from SQL (In my example the DBA changed the type of a column from string to date which caused a cast issue because I was expecting a string which I was casting to a date.

    Todd

    Top 100 Contributor
    80 Posts

    I updated to 4.5.7 and this "feature" went away.  I am getting error messages back to Silverlight from the data portal again. 

    Page 1 of 1 (9 items) | RSS

    Copyright (c) 2006-2014 Marimer LLC. All rights reserved.
    Email admin@lhotka.net for support.
    Powered by Community Server (Non-Commercial Edition), by Telligent Systems