Forum Xamarin Xamarin.Forms

UWP and AzureMobileService Offline SQLite Sync problem when building with .Net Native Toolchain on.


We have a problem when we build our app in Release mode with .Net Native Toolchain on.

MobileServiceClient.SyncContext.PendingOperations then returns -1 instead of 0 when there are no Pending Operations which result in that offline functionality no longer works (no items that are inserted when you are offline are sent over to the server).

The same phenomenon is described here:

We have tested with Visual Studio Update 2 and also with Visual Studio Update 3, but unfortunately, the problem remains in that version.

However, we have noticed that if we set "Optimize code" = false the offline functionality works, but then we instead get the following errors when Windows App Certification Kit tests have been completed.

"AppName" takes a dependency on Microsoft .Net Native Framework Package 1.x framework but is missing the framework dependency declaration in the manifest.


API CoCreateInstance in api-ms-win-core-com-l1-1-0.dll is not supported for this application type. "AppName.dll" calls this API.

If anyone has a solution for this, we would be very grateful!

Best Answer


  • BradChase.2654BradChase.2654 USMember ✭✭✭
    edited February 2017

    @TorbjrnRosendahl Sorry for bringing up an old topic but I have the same issue with our release version. I also use Newtonsoft but we also use other libraries. Can you explain how you were able to deduce it to being Newtonsoft? I would like to walk our libraries the way I suppose you did and figure out the exact ones.

    Thanks much!

    EDIT: Also did you have to add it to every library? Or just the main application library?

  • No problem, I'm glad if I can help.

    As I wrote, I got the help from a member in the "Native .NET runtime and compiler team" and he advised me that I could exclude certain methods from the assemblies.

    I looked around in the source code for "AzureMobileService" on Github, looking for where "MobileServiceClient.SyncContext.PendingOperations" was called. I saw that "NewtonSoft" was used in several places but I did not make "the connection" at the time...

    Then I began to exclude classes and methods where "PendingOperations" was called but it did not work so I started to exclude entire assemblies from the project (with DoNotOptimize="true" DoNotInline="true") and suddenly it started to work. By "process of elimination" I then realized that it was due to "NewtonSoft".

    No, I just added it to the main application (the Xamarin.forms UWP project).

Sign In or Register to comment.