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

In this post, you will learn about sync provider notifications in Windows 11 and how to disable or enable it...
In this tutorial, let’s learn how to enable or disable the startup sound in Windows 11. By default, when Windows...
The CameraCaptureTask allows the Windows Phone 7 App to launch the Camera Application . This will be useful when the...