I know that this is old post, but now you can use inject : IPreferences preferences
and register it in DI using :
services.AddSingleton(PhoneDialer.Default);
services.AddSingleton(Preferences.Default);
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I am migrating one Xararin Forms project to MAUI. The application code works fine. On the unit testing side of it some of the places App.Properties was used which is now replaced with Microsoft.Maui.Storage.Preferences but this doesn't seem to be working in Unit testing code. It also throws error if it is used in the App code and called from the unit test method.
I am using NUnit test package.
This is the error I am getting :
Microsoft.Maui.ApplicationModel.NotImplementedInReferenceAssemblyException: "This functionality is not implemented in the portable version of this assembly. You should reference the NuGet package from your main application project in order to reference the platform-specific implementation." at Microsoft.Maui.Storage.PreferencesImplementation.SetT\n at Microsoft.Maui.Storage.Preferences.Set(String key, String value, String sharedName)\n at Microsoft.Maui.Storage.Preferences.Set(String key, String value)\n at Medtronic.OneApp.Application.Core.Test.IntegrationTests.AppxamlTest.TestNaviagtionRestoreIsNotDoneWhenAppIsNotLaunched() in ~/App.xaml.Test.cs:231
I know that this is old post, but now you can use inject : IPreferences preferences
and register it in DI using :
services.AddSingleton(PhoneDialer.Default);
services.AddSingleton(Preferences.Default);