'UWP: AccessViolationException on an attempt to open a page

I have a Xamarin.Forms application that uses FreshMvvm. On an attempt to open a particular page with this code:

await CoreMethods.PushPageModel<DistributorsLocatorPageModel>();

after the execution passes the page's Init() method and all properties, the app crashes with the following error:

System.AccessViolationException

HResult=0x80004003

Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Source=Cannot evaluate the exception source

StackTrace: Cannot evaluate the exception stack trace

This happens only in UWP. iOS and Android have no issue. And other pages also open fine even in UWP.

I would appreciate your suggestions.



Solution 1:[1]

just found this through desperate googling and didn't find much in the way of answers.

one thing i'll say for it is that the issue lies in thread safety - when navigation is done explicitly on the main thread the problem doesn't arise, however if you're using AppShell navigation on a tabpage or some other place where you don't invoke the navigation in your own code, there doesn't seem to be a lot you can do.

I'm currently attempting to find a good place to override OnNavigatedTo, but so far have come up short.

so I guess this is a long way of saying "bump"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sal K