80131500: stowed_exception_realms.exceptions.realmexception


#1

Not Xamarin but there is no DotNet or UWP category. This exception is fired on a SaveOrder transaction in our app but only pops up in the Visual Studio Crash Center every couple of days so I guess it only fires in a tiny proportion of cases ~<0.1% so it is a low level chronic pathology.

We’ve been unable to replicate the issue on our dev machines.

Here are the last few stack frames

Realms::ObjectHandle SetString() ObjectHandle.cs:240
Realms::RealmObject SetStringValue() RealmObject.cs:303
Shared::Data::Customer::RealmHelper CopyToRealm() +0x000000000000008E

So something wobbles down in Realm when Order.Customer is being saved. Customer looks like this

internal class Customer : RealmObject
{
    [PrimaryKey]
    [MapTo(nameof(CustomerId))]
    private string _CustomerId { get; set; } = Guid.NewGuid().ToString();
    public string CustomerId
    {
        get => _CustomerId;
        set
        {
            if (string.IsNullOrWhiteSpace(value))
                throw new Exception("CustomerId cannot be null");
            _CustomerId = value;
        }
    }
    [MapTo(nameof(Category))]
    private CustomerCategory _Category { get; set; } = RealmService.DefaultCustomerCategory();
    public CustomerCategory Category
    {
        get => _Category;
        set => _Category = value ?? throw new Exception("Customer Category cannot be null");
    }
    [Required]
    public string FileAs { get; set; }
    public string BusinessName { get; set; }
    public string FamilyName { get; set; }
    public string GivenName { get; set; }
    public string Title { get; set; }
    public string Street { get; set; }
    public string Locality { get; set; }
    public string Region { get; set; }
    public string PostCode { get; set; }
    public string AddressLabel { get; set; }
    public string MobileNr { get; set; }
    public string Phone1 { get; set; }
    public bool SendOrderCompletedSMS { get; set; }
    public string Note { get; set; }
    public string Email { get; set; }
    public DateTimeOffset DateEntered { get; set; }
    public DateTimeOffset? DateReminder { get; set; }
    public bool IncludeInThisMailout { get; set; }

    [Backlink(nameof(Order.Customer))]
    internal IQueryable<Order> Orders { get; }

    [Backlink(nameof(MailingList.Customers))] // Refer Backlinks and Many-To-Many Relationships
    internal IQueryable<MailingList> MailingLists { get; } // https://forums.realm.io/t/backlinks-and-many-to-many-relationships/1473/2
    private Customer()
    {
    }
    public Customer(CustomerCategory customerCategory) => this.Category = customerCategory ?? throw new Exception("Customer Category cannot be null");

    public override string ToString() => FileAs;
}

SaveOrder Saves the order, customer, order details. Each order detail might be a product with lots of components so there is lots going on in a single write.

We’ve recently made SaveOrder async hoping to ease the pain but the error still pops up now and then.

Any suggestions as to what we might do to shore things up?


#2

Can you post the entire stacktrace?


#3
With pleasure:
Realm.dll
    Realms::ObjectHandle SetString() ObjectHandle.cs:240
    Realm.dll
    Realms::RealmObject SetStringValue() RealmObject.cs:303
    Shared.dll
    Shared::Data::Customer::RealmHelper CopyToRealm() +0x000000000000008E
    Realm.dll
    Realms::Realm AddInternal() Realm.cs:574
    Realm.dll
    Realms::Realm.Add_System __Canon_() Realm.cs:509
    Shared.dll
    Shared::Data::Order::RealmHelper CopyToRealm() +0x0000000000000123
    Realm.dll
    Realms::Realm AddInternal() Realm.cs:574
    Realm.dll
    Realms::Realm.Add_System __Canon_() Realm.cs:509
    Shared.dll
    Shared::Services::OrderService::__c__DisplayClass16_0 _SaveItemAsync_b__0() OrderService.cs:309
    Realm.dll
    Realms::Realm::__c__DisplayClass48_1 _WriteAsync_b__2() Realm.cs:687
    SharedLibrary.dll
    System::Func$1_System::Threading::Tasks::VoidTaskResult_ Invoke() Invoke:16707566
    Realm.dll
    Realms::Realm Write() Realm.cs:632
    Realm.dll
    Realms::Realm::__c__DisplayClass48_0 _WriteAsync_b__1() Realm.cs:687
    SharedLibrary.dll
    System::Func$1_System::Threading::Tasks::VoidTaskResult_ Invoke() Invoke:16707566
    SharedLibrary.dll
    System::Threading::Tasks::Task InnerInvoke() Task.cs:2474
    SharedLibrary.dll
    System::Threading::Tasks::Task Execute() Task.cs:2319
    SharedLibrary.dll
    System::Runtime::ExceptionServices::ExceptionDispatchInfo Throw() ExceptionDispatchInfo.cs:63
    SharedLibrary.dll
    System::Runtime::CompilerServices::TaskAwaiter ThrowForNonSuccess() TaskAwaiter.cs:186
    SharedLibrary.dll
    System::Runtime::CompilerServices::TaskAwaiter HandleNonSuccessAndDebuggerNotification() TaskAwaiter.cs:154
    SharedLibrary.dll
    System::Runtime::CompilerServices::TaskAwaiter ValidateEnd() TaskAwaiter.cs:125
    SharedLibrary.dll
    System::Runtime::CompilerServices::TaskAwaiter GetResult() TaskAwaiter.cs:515
    Realm.dll
    Realms::Realm::__c__DisplayClass48_0::__WriteAsync_g__doWorkAsync0_d MoveNext() +0x00000000000000D7
    SharedLibrary.dll
    System::Runtime::ExceptionServices::ExceptionDispatchInfo Throw() ExceptionDispatchInfo.cs:63
    SharedLibrary.dll
    System::Runtime::CompilerServices::TaskAwaiter ThrowForNonSuccess() TaskAwaiter.cs:186
    SharedLibrary.dll
    System::Runtime::CompilerServices::TaskAwaiter HandleNonSuccessAndDebuggerNotification() TaskAwaiter.cs:154
    SharedLibrary.dll
    System::Runtime::CompilerServices::TaskAwaiter ValidateEnd() TaskAwaiter.cs:125
    SharedLibrary.dll
    System::Runtime::CompilerServices::TaskAwaiter GetResult() TaskAwaiter.cs:515
    Shared.dll
    Shared::Services::OrderService::_SaveItemAsync_d__16 MoveNext() +0x0000000000000567
    SharedLibrary.dll
    System::Runtime::ExceptionServices::ExceptionDispatchInfo Throw() ExceptionDispatchInfo.cs:63
    SharedLibrary.dll
    System::Runtime::CompilerServices::TaskAwaiter ThrowForNonSuccess() TaskAwaiter.cs:186
    SharedLibrary.dll
    System::Runtime::CompilerServices::TaskAwaiter HandleNonSuccessAndDebuggerNotification() TaskAwaiter.cs:154
    SharedLibrary.dll
    System::Runtime::CompilerServices::TaskAwaiter ValidateEnd() TaskAwaiter.cs:125
    UUWP.exe
    UUWP::ViewModels::OrderPageViewModel::_SaveOrderAsync_d__182 MoveNext() OrderPageViewModel.cs:410
    SharedLibrary.dll
    System::Runtime::ExceptionServices::ExceptionDispatchInfo Throw() ExceptionDispatchInfo.cs:63
    SharedLibrary.dll
    System::Runtime::CompilerServices::TaskAwaiter ThrowForNonSuccess() TaskAwaiter.cs:186
    SharedLibrary.dll
    System::Runtime::CompilerServices::TaskAwaiter HandleNonSuccessAndDebuggerNotification() TaskAwaiter.cs:154
    SharedLibrary.dll
    System::Runtime::CompilerServices::TaskAwaiter ValidateEnd() TaskAwaiter.cs:125
    SharedLibrary.dll
    System::Runtime::CompilerServices::TaskAwaiter GetResult() TaskAwaiter.cs:515
    UUWP.exe
    UUWP::Views::OrderPage::_SaveOrderAsync_d__24 MoveNext() +0x000000000000008C
    SharedLibrary.dll
    System::Runtime::ExceptionServices::ExceptionDispatchInfo Throw() ExceptionDispatchInfo.cs:63
    SharedLibrary.dll
    System::Runtime::CompilerServices::AsyncMethodBuilderCore::__c _ThrowAsync_b__7_0() AsyncMethodBuilder.cs:931
    SharedLibrary.dll
    System::Func$2_System::__Canon,System::TimeSpan_ Invoke() Invoke:16707566
    SharedLibrary.dll
    System::Threading::WinRTSynchronizationContext::Invoker InvokeCore() SynchronizationContext.WinRT.cs:81
    System.Private.Interop.dll
    System::Runtime::InteropServices::McgMarshal ThrowOnExternalCallFailed() McgMarshal.cs:1189
    UUWP.McgInterop.dll
    __Interop::ComCallHelpers Call() Call:15732480
    UUWP.McgInterop.dll
    __Interop::ForwardComStubs.Stub_10_System __Canon_() Stub_10:16707566
    Microsoft.AppCenter.dll
    Microsoft::AppCenter::Utils::ApplicationLifecycleHelper._ ctor_b__17_1() +0x000000000000003D
    SharedLibrary.dll
    System::Runtime::ExceptionServices::ExceptionDispatchInfo Throw() ExceptionDispatchInfo.cs:63
    Microsoft.AppCenter.dll
    Microsoft::AppCenter::Utils::ApplicationLifecycleHelper._ ctor_b__17_1$catch$0() +0x0000000000000030
    SharedLibrary.dll
    System::UnhandledExceptionEventHandler Invoke() Invoke:16707566
    UUWP.McgInterop.dll
    __Interop::Intrinsics.HasThisCall__24_System __Canon_() +0x0000000000000036
    UUWP.McgInterop.dll
    __Interop::ReverseComStubs.Stub_6_System __Canon_() Stub_6:16707566

#4

Okay, that wasn’t as helpful as I thought it would :confused: It seems like you’re getting a RealmException which is kind of like a catch-all for exceptions that don’t have a custom type, in which case the message usually provides some pointers as to what went wrong. I’m not familiar with VS Crash Center, but is there a way to extract the exception message from the crash report?


#5

It’s actually Visual Studio App Center. It’s a port of HockeyApp.

The exception is the title of this thread. The stack trace is all we get. No detailed exception message.


#6

Sometimes you can get a hint by looking up the hresult 80131500. But I haven’t been able to find it.


#7

I can see the exception type in the title - it’s RealmException, but not the exception message, which would contain more clues to what’s going on.


#8

Yes, more clues would be good :wink: Microsoft bought HockeyApp a year or two ago as you probably know and have ported it to Visual Studio App Center Diagnostics. I’ve read somewhereabout that the port is incomplete for UWP.

I’ve also read somewhereabout that Stowed Exceptions are a UWP attempt to bubble up more complete exception information but there is something about the layering of WinRT that makes this problematic and it’s a work-in-progress.

So maybe with time we’ll see more complete error info for this issue. I’ll post back here if I see anything more useful


#9

Do you know if that’s an exception that crashes the app (like a native error) or is it something that can be caught in .NET? The stacktrace seems to imply the latter, so maybe you can setup your own UnhandledExceptionEventHandler which sends the info to VS App Center? I haven’t used HockeyApp, but I remember Xamarin Insights (which I believe was also merged into VS App Center) had a functionality where you manually submit exceptions and you could augment them with some metadata on submission. So if there’s still a similar API, you could try augmenting the error report with the exception message (which should kind of have been automatic, Microsoft :expressionless:).


#10

We used UnhandledExceptionEventHandler before we started using VS App Center. That would be great as HockeyApp would then allow us to send the error to diagnostics with Crashes.TrackError

Alas App Center Diagnostics does not (yet) Support handled exceptions for UWP apps #669

Perhaps we could ask all our friends to upvote Support handled exceptions for UWP apps #669