locked
Error Accessing State Store for Windows Store App

    Question

  • I am attempting to save & access my app's state using ApplicationData.Current.LocalSettings & ApplicationData.Current.LocalFolder. When I do this, I receive the following error:

    An exception of type 'System.Exception' occurred in MyWindowsApp.exe but was not handled in user code

    WinRT information: Error trying to initialize the application data container server

    Additional information: Loading the state store failed.

    I'm sure this is just something getting messed up or needing reset or reconfigured for the app, because it seemed to work before with no problem, but I can't seem to figure out how to fix it. Can somebody help me? Thanks.


    Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/

    Friday, August 8, 2014 1:43 AM

Answers

All replies

  • Try uninstalling the app from the device

    Jeff Sanders (MSFT)

    @jsandersrocks - Windows Store Developer Solutions @WSDevSol
    Getting Started With Windows Azure Mobile Services development? Click here
    Getting Started With Windows Phone or Store app development? Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

    Friday, August 8, 2014 12:38 PM
    Moderator
  • I tried that, it didn't seem to help. Any other ideas?

    Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/

    Friday, August 8, 2014 3:30 PM
  • the isostorespy tool on codeplex will allow you to see the files.  Try removing them using that tool.

    Jeff Sanders (MSFT)

    @jsandersrocks - Windows Store Developer Solutions @WSDevSol
    Getting Started With Windows Azure Mobile Services development? Click here
    Getting Started With Windows Phone or Store app development? Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

    Friday, August 8, 2014 3:32 PM
    Moderator
  • I couldn't find that tool on CodePlex. Do you have a link to it? Thanks.

    Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/

    Friday, August 8, 2014 3:44 PM
  • Sure!

    http://www.codeplex.com/site/search?query=isostore&ac=4


    Jeff Sanders (MSFT)

    @jsandersrocks - Windows Store Developer Solutions @WSDevSol
    Getting Started With Windows Azure Mobile Services development? Click here
    Getting Started With Windows Phone or Store app development? Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

    Friday, August 8, 2014 3:47 PM
    Moderator
  • From what I can tell, that is only for Windows Phone apps, but my app is Windows 8.1 (not Windows Phone 8.1). Is it possible to use it with Windows 8.1? Thanks.

    Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/

    Friday, August 8, 2014 4:19 PM
  • Oh Nathan... So sorry!  I am in both forums a lot and got them confused.

    You can manually clear the folder where the app is stored.

    When you develop an app and run it from VS it will store it in this folder:

    C:\>cd %userprofile%\AppData\Local\Packages

    (you may need to go in as an administrator and get privileges to that folder).

    Then find your app package folder (will start with the name of your app under Packaging, Package Name in the manifest).

    Uninstall the app and if that sub folder for your app is still there, you can try deleting it.  Be careful that you only delete your app in development!


    Jeff Sanders (MSFT)

    @jsandersrocks - Windows Store Developer Solutions @WSDevSol
    Getting Started With Windows Azure Mobile Services development? Click here
    Getting Started With Windows Phone or Store app development? Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

    Friday, August 8, 2014 5:31 PM
    Moderator
  • No problem, I think that fixed it now. However, I now get the following error when my code tries to create the file:

    An exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll but was not handled in user code

    Additional information: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

    The code that I use to create & access the file is:

    Public Module SaveLoadExtensions
    	<Extension()> Public Async Sub Save(players As PlayerData())
    		Dim tempfile As StorageFile = Await ApplicationData.Current.LocalFolder.CreateFileAsync("Players.xml", CreationCollisionOption.ReplaceExisting)
    		Dim xml As New XmlSerializer(GetType(PlayerData()), New XmlRootAttribute("Players"))
    		Dim sw As New StringWriter()
    		xml.Serialize(sw, players)
    		Await FileIO.WriteTextAsync(tempfile, sw.ToString())
    	End Sub
    	<Extension()> Public Async Function Load(players As PlayerData()) As Task(Of PlayerData())
    		Try
    			Dim tempfile As StorageFile = Await ApplicationData.Current.LocalFolder.GetFileAsync("Players.xml")
    			Dim sr As New StringReader(Await FileIO.ReadTextAsync(tempfile))
    			Return CType(New XmlSerializer(GetType(PlayerData()), New XmlRootAttribute("Players")).Deserialize(sr), PlayerData())
    		Catch ex As Exception
    			'File does not exist
    			Return {}
    		End Try
    	End Function
    End Module
    This code is in another project (a Portable Class Library I am using for this Universal App). The interesting thing is, even though I receive this error, the next time I attempt to run/debug it, it loads the data from the file, so it did create it, so it is giving me an error even though it actually is creating the file and is able to read it. Is there something extra I need to do because my code is in another project? Why do I receive the error when writing the file but not when reading it? (if this question needs to be posted as a separate thread, just tell me so I can repost it) Thanks.

    Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/

    Friday, August 8, 2014 10:49 PM