InvalidOperationException – You can only use State between OnNavigatedTo and OnNavigatedFrom

If you are receiving the below error in your Windows Phone App, have a look at the place where you are accessing the State dictionary in the Page. It could be possible that you are accessing the State dictionary within the constructor etc.

An exception of type ‘System.InvalidOperationException’ occurred in Microsoft.Phone.ni.dll but was not handled in user

Message: You can only use State between OnNavigatedTo and OnNavigatedFrom

InvalidOperationException - You can only use State between OnNavigatedTo and OnNavigatedFrom

The State dictionary in your page can only be used after the OnNavigatedTo event is called or before the OnNavigatedFrom is called. Accessing the Application State at the right time will resolve this issue.

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

This blog post will guide you through several effective methods to troubleshoot and resolve the issue of Microsoft Edge not...
Windows 11 offers a range of audio enhancements that can enrich your listening experience. These enhancements include features like virtual...
Windows 11 brings a fresh and visually stunning design to your desktop, and one of the standout features is the...