Error when registering a Singleton #3255
Replies: 1 comment 3 replies
-
Yes if you read the error it tells you exactly what the problem is you are registering the interface with no concrete implementation therefore it will have an issue with the registration because there is no way that it could create a new instance. // Won't work...
builder.Services.AddSingleton<IMessage>();
builder.Services.AddSingleton<ILodingPageService>();
// Would work...
builder.Services.AddSingleton<IMessage, MessageService>();
builder.Services.AddSingleton<ILodingPageService, LoadingPageService>(); |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We are migrating our old xamarin app to the new MAUI one.
In the xamarin verision we used this code to instantiate the singleton
builder.Services.AddSingleton<IMessage>(); builder.Services.AddSingleton<ILodingPageService>();
but compiling this error comes out:
So we tried to use the RegisterSingleton of your great prism library as shown in the image but we have the same but from the builder...
How do we have to treat that code now that the simple MAUI singleton is not working like in xamarin?
Thank you very much
Angelo
Beta Was this translation helpful? Give feedback.
All reactions