When I run a UWP app in Debug mode, ApplicationData
exists.
When I run in Release mode, it seems ApplicationData
has gone out of scope. Rather, accessing it times out.
I've added two lines to a stock UWP Blank page app solution:
sealed partial class App : Application
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
this.InitializeComponent();
string strPath =
Windows.Storage.ApplicationData.Current.LocalFolder.Path; // <<< Added
System.Diagnostics.Debug.WriteLine(strPath); // <<< Added
this.Suspending += OnSuspending;
}
//...
Running in debug mode, ApplicationData.Current.LocalFolder.Path
exists, and strPath
is something like...
C:\Users\AUser\AppData\Local\Packages\[some guid-like number]_7442be4pe7dnc\LocalState
Running in Release mode, if I check up on things in the Immediate Window, I get this...
ApplicationData.Current.LocalFolder.Path,nq
The name 'ApplicationData' does not exist in the current context
And hovering over the code itself gives me a strange timeout:
If ApplicationData
isn't in scope in a release app, how do I get to the folder? If it is supposed to be in scope, why wouldn't it be here?
EDIT: Same thing happens when I try to access ApplicationData
in a click event for a button, so it's not a timing/initialization thing.