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’ll learn about the Win32 Error “0x000019E5 – ERROR_COULD_NOT_RESIZE_LOG” that you get when debugging system erors in...
In this post, you’ll learn about the error “CO_E_DBERROR 0x8004E02B” that is returned when working with COM based APIs or...
In this post, you’ll learn about the Win32 Error “0x000019D0 – ERROR_LOG_BLOCK_VERSION” that you get when debugging system erors in...