Realm.GetInstanceAsync(config) call fails - Could it be embedded objects?

I had a (working) single-realm realm-app, which has now been partitioned into 3 realms.
Momentarily worked fine.
A smaller Android version which just needed to access one of the realms tried to link but failed.
Sorted out the problem (field nullable on one side not the other). This now connects and syncs.
Since then, the Mother app crashes with the dreaded 0xc0000409 error and tells Microsoft about the problem! (I presume the problem here is the lack of an intermediate JNI-like layer in Dot-net).
The Logs show everything is fine.
The crash happens at Realms.Realm.GetInstanceAsync(config) call.
Interestingly, it occurs on all three of the realms individually.
Is there any way at all of finding out what the issue is?

Maybe it’s Embedded objects. A couple of questions:

  1. Do embedded objects need an _id and/or a partitionKey. I can’t see why they should, they are, after all, embedded in the parent.
  2. I assume that embedded objects can’t have a collection defined.

Thanks a lot

Ugh! That crash is concerning. Does this reproduce consistently and do you have anything meaningful in the client logs before the crash?

To your questions - no, embedded objects don’t need _id and partition field and no, they can’t have their own collections.

On a side note, for bug/crash reports, you’ll get faster response times if you file a GitHub issue directly as engineers will prioritize those over community forums (which is why it took so long to get a response here - sorry about that :sweat:).

Thanks for your reply. It wasn’t so urgent because we have another version without the embedded objects.
However, I do prefer the embedded system.

I seem to have found the problem:
The Android embedded objects have to have optional bools. These were changed to optional in the Dot-net version and the app no longer crashes. I terminated sync, restarted and the Dot-net mother app has finally synced.
Worth mentioning in the documentation, although I don’t think there are too many users syncing Android and Dot-net apps yet.

Shame you can’t find a way of tunnelling an error or exception through to the user on dot-net.
Android is more informative.

The documentation for Embedded objects is really confusing. The Dot-net example shows an Object Id and a partition field, whereas the IOS and Android version don’t.
Oddly, the schema examples show declarations of the string fields like:
“properties”: {
“street”: “string”,
“city”: “string”,
“country”: “string”,
“postalCode”: “string”
However I get “invalid JSON schema” when saving these.
I have to do the full monty
“properties”: {
“street”: {bysonType: “string”},

Thanks again, I will check out the Github issues.

Hey, thanks for the feedback and glad to hear things are working now! I filed docs tickets to remove the _id and _partition properties from the .NET example - they shouldn’t have been there. I also filed a ticket to fix the JSON Schema declaration.

Regarding the nullability of properties - in Java, if you use Boolean, the field will be optional, but boolean will be required. Those are equivalent to bool? and bool in C#.

Finally, in the Cloud portal, we have a page that shows the data models for the various languages so you don’t have to manually type it out. So if you start with Android, turn on dev mode, sync your schema, then turn off dev mode, you’ll be able to just copy-paste the C# models, and since those are generated from the JSON Schema, they’ll match exactly the Android types. Here’s an example:

Obviously, since those are generated, they may not match precisely your coding style preferences, so you may need to adjust them, but should eliminate those pesky hard to track inconsistencies where a type is nullable in one language but required in another.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.