Closed alsuomi closed 3 months ago
Hi I'm an AI powered bot that finds similar issues based off the issue title.
Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!
Note: You can give me feedback by thumbs upping or thumbs downing this comment.
Hi @alsuomi , the error you're seeing is because the MAUI Essentials APIs are not generally available outside of .NET MAUI apps. So, in a Blazor Web app (running on ASP.NET Core), the API throws an exception. As such, this issue is a duplicate of #17317.
To make this work in your app, consider having an interface such as ILanguageLoader
that has an API async Task<...> ReadLanguageJsonAsync();
with two implementations: a .NET MAUI implementation that uses MAUI Essentials, and an ASP.NET implementation that uses appropriate APIs for that platform.
You can look at this pattern in the project template with the IFormFactor
sample interface and the two implementations of it.
Thanks for the reply @Eilon .
I believe that we are talking about Maui Blazor "Hybrid". It means that one implementation must work everywhere. It must be handled and dealt (interface implementation) on the Maui APIs side. Not on the user side.
Bug problem for developers, those who haven't got experience on neither Maui nor Blazor
@alsuomi the request to make MAUI Essentials APIs work outside of .NET MAUI is tracked by this related issue: https://github.com/dotnet/maui/issues/17317
As of right now it's 'by design' because the MAUI Essentials API were only designed to workin within MAUI. But it's certainly something that we could reconsider.
Discussed in https://github.com/dotnet/maui/discussions/23661