Skip to content

Data Persistence Issue with MAUI .NET 8 #9627

Closed
@vsfeedback

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:

  1. Develop a .NET MAUI application that utilizes Preferences or SecureStorage to store persistent data.
  2. Compile and deploy the app to a physical or virtual device.
  3. Use the app to save some data via Preferences or SecureStorage.
  4. Perform a new build and deploy the updated version of the app to the same device without uninstalling the previous version.
  5. 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:

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.

Metadata

Labels

Area: App+Library BuildIssues when building Library projects or Application projects.need-infoIssues that need more information from the author.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions