Description
This issue has been moved from a ticket on Developer Community.
[severity:It's more difficult to complete my work]
I am encountering an issue while working on a .NET MAUI project using Visual Studio 2022 v.17.12.3 with .NET 8. Specifically, the problem involves the loss of application data when deploying a new build in both Debug and Release modes.
Here are the steps to reproduce the issue:
- Develop a .NET MAUI application that utilizes Preferences or SecureStorage to store persistent data.
- Compile and deploy the app to a physical or virtual device.
- Use the app to save some data via Preferences or SecureStorage.
- Perform a new build and deploy the updated version of the app to the same device without uninstalling the previous version.
- Observe that all previously saved data is lost after the new deployment.
Important Notes:
- If the app is closed and reopened without deploying a new build, the data persists correctly.
- The "Preserve Application Data Cache on device Between Deploys" option is enabled in the Visual Studio settings.
- This issue occurs consistently in both Debug and Release mode.
- The problem is reproducible on both an Android emulator (Pixel 7 with API 34) and a physical device running Android 10.
I have reviewed similar issues reported in the Developer Community but could not find a working solution for my case:
- Visual Studio 17.10 MAUI .NET 8 Android Issue
- Xamarin and Android Deploy Problem
- Visual Studio 17.8 MAUI .NET 8 Android Issue
Expected Behavior: Data stored using Preferences or SecureStorage should persist across deployments when the "Preserve Application Data Cache on device Between Deploys" option is enabled.
Actual Behavior:
All saved data is lost after deploying a new build to the device in Debug mode.
Environment Details:
- Visual Studio Version: 2022 v.17.12.3
- Project Type: .NET MAUI
- Target Framework: .NET 8
- Deployment Platform: Android
- Emulator: Pixel 7 (Android API 34)
- Physical Device: Android 10
Please provide guidance or a workaround to resolve this issue. Thank you!
Original Comments
Feedback Bot on 12/12/2024, 05:48 PM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.