microsoft / microsoft/WindowsAppSDK
Self-Contained App Crashes When Using ApplicationDataContainer
- Dominant language
- C++
- Stars
- 4.7k
- Forks
- 471
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 28
Description
### Discussed in https://github.com/microsoft/WindowsAppSDK/discussions/2618
Originally posted by **anlocnghg** June 13, 2022
My app previously used 'framework-dependent' deployment (it installed in an user local app folder and could be distributed via Microsoft Store). However, due to our organization's requirements that only xCopy deployment is allowed, meaning self-contained app. I followed the instruction ([Link](https://docs.microsoft.com/en-us/windows/apps/package-and-deploy/self-contained-deploy/deploy-self-contained-apps)), everything initially was okay. Only until I started using the **ApplicationDataContainer**, for example:
```
private void myButton_Click(object sender, RoutedEventArgs e)
{
myButton.Content = "Button Clicked";
// App crashes
var localSettingContainer = Windows.Storage.ApplicationData.Current.LocalSettings;
}
```
I know that since the xCopy deployment (self-contained app), there is no user local storage folder for the installed app. I would like to ask what is the best way to walkaround this issue to be able to reuse to ApplicationDataContainer, or any other app settings container API?
Thank you very much!
-----------------------------------------
Below is steps to reproduce the crash:
1. Create a new WinUI3 app
2. Make this app self-contained by editing the project file following [this link](https://docs.microsoft.com/en-us/windows/apps/package-and-deploy/self-contained-deploy/deploy-self-contained-apps).
3. Created a variable referencing to Windows.Storage.ApplicationData.Current.LocalSettings in a Button Clicked handler, for example:
`var localSettingContainer = Windows.Storage.ApplicationData.Current.LocalSettings;`
4. Run and the app crashes when the button clicked
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.