jamesmontemagno / SettingsPlugin

Read and Write Settings Plugin for Xamarin and Windows
MIT License
324 stars 80 forks source link

Xam.Plugin.Settings Nuget Package giving System.NotImplemented Exception when i am trying to Register using Autofac For IOS(.NET MAUI). #168

Open KotiChallaDev opened 6 months ago

KotiChallaDev commented 6 months ago

I am using Xam.Plugin.Settings nuget package to register user settings and i am registering that nuget package through Autofac with this code

var containerBuilder = new ContainerBuilder(); containerBuilder.RegisterInstance(CrossSettings.Current).ExternallyOwned().As(); in .NET MAUI ios App and i am using .net 8.0

Version Number of Plugin:3.1.1 Device Tested On: Mac mini Ventura 13.5.2 Simulator Tested On: Ios 14 version 16.4 Version of VS: 17.6.10 Version of Xamarin: Versions of other things you are using:

Steps to Reproduce

In MauiProgram.cs try to register CrossSettings.Current using Autofac

Expected Behavior

It need to Register the CrossSettings.current

Actual Behavior

Here is the Application Output For My ios Simulator where Exception is coming

Resolved pending breakpoint at 'MauiProgram.cs:27,1' to Microsoft.Maui.Hosting.MauiApp EHRSUIT.MauiProgram.CreateMauiApp () [0x00000].

2024-03-22 15:00:32.993936+0530 EHRSUIT[17885:269731]

Unhandled Exception:

System.NotImplementedException: 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 Plugin.Settings.CrossSettings.get_Current()

at EHRSUIT.MauiProgram.CreateMauiApp() in /Users/jigneshparmar/Projects/EHRSUIT/EHRSUIT/MauiProgram.cs:line 76

at EHRSUIT.AppDelegate.CreateMauiApp() in /Users/jigneshparmar/Projects/EHRSUIT/EHRSUIT/Platforms/iOS/AppDelegate.cs:line 11

at Microsoft.Maui.MauiUIApplicationDelegate.WillFinishLaunching(UIApplication application, NSDictionary launchOptions)

at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName)

at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass)

at EHRSUIT.Program.Main(String[] args) in /Users/jigneshparmar/Projects/EHRSUIT/EHRSUIT/Platforms/iOS/Program.cs:line 13

2024-03-22 15:00:32.998055+0530 EHRSUIT[17885:269731] Unhandled managed exception: 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. (System.NotImplementedException)

at Plugin.Settings.CrossSettings.get_Current() Code Snippet

var containerBuilder = new ContainerBuilder(); containerBuilder.RegisterInstance(CrossSettings.Current).ExternallyOwned().As();

ScreenShot

image

Note :- CrossSetting,Current is perfectly working for Android Platform it is only giving this Exception in IOS