davidortinau / WeatherTwentyOne

MIT License
927 stars 220 forks source link

Empty main page content while running on Windows (10.0.19043) #33

Open Davidoutz opened 3 years ago

Davidoutz commented 3 years ago

I installed all prerequisites for .Net MAUI, the latest VS 2022 (17.0.0 Preview 2.1) and the maui-check. Everything looks good from this perspective and I can create a new maui project and run it on any platform. Nevertheless I've tried to download and run the weather app as is. While it's working fine on android, on windows (10.0.19043) it shows the first page but no content nor the menu/tabbar.

image

I see from the output that it cannot fetch a font for some reasons:

Microsoft.Maui.FontManager: Error: Error loading font 'ms-appx:///Assets/OpenSans-SemiBold.ttf'.

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.Runtime.InteropServices.COMException (0x80040154): Classe non enregistrée (0x80040154 (REGDB_E_CLASSNOTREG))
   at WinRT.BaseActivationFactory..ctor(String typeNamespace, String typeFullName) in Microsoft.Graphics.Canvas.Interop.dll:token 0x6000023+0x6e
   at WinRT.ActivationFactory`1..ctor() in Microsoft.Graphics.Canvas.Interop.dll:token 0x6000027+0x0
   at System.RuntimeType.CreateInstanceOfT() in System.Private.CoreLib.dll:token 0x6000681+0x3e
   --- End of inner exception stack trace ---
   at System.RuntimeType.CreateInstanceOfT() in System.Private.CoreLib.dll:token 0x6000681+0x4e
   at System.Activator.CreateInstance[T]() in System.Private.CoreLib.dll:token 0x60009a4+0x0
   at WinRT.WeakLazy`1.get_Value() in Microsoft.Graphics.Canvas.Interop.dll:token 0x6000019+0x20
   at WinRT.ActivationFactory`1.As(Guid iid) in Microsoft.Graphics.Canvas.Interop.dll:token 0x600002a+0x0
   at Microsoft.Graphics.Canvas.Text.CanvasFontSet._ICanvasFontSetFactory..ctor() in Microsoft.Graphics.Canvas.Interop.dll:token 0x6003792+0x1c
   at System.RuntimeType.CreateInstanceOfT() in System.Private.CoreLib.dll:token 0x6000681+0x3e
   --- End of inner exception stack trace ---
   at System.RuntimeType.CreateInstanceOfT() in System.Private.CoreLib.dll:token 0x6000681+0x4e
   at System.Activator.CreateInstance[T]() in System.Private.CoreLib.dll:token 0x60009a4+0x0
   at WinRT.WeakLazy`1.get_Value() in Microsoft.Graphics.Canvas.Interop.dll:token 0x6000019+0x20
   at Microsoft.Graphics.Canvas.Text.CanvasFontSet._ICanvasFontSetFactory.get_Instance() in Microsoft.Graphics.Canvas.Interop.dll:token 0x6003793+0x0
   at Microsoft.Graphics.Canvas.Text.CanvasFontSet.<>c__DisplayClass8_0.<.ctor>b__0() in Microsoft.Graphics.Canvas.Interop.dll:token 0x60037a2+0x0
   at Microsoft.Graphics.Canvas.Text.CanvasFontSet..ctor(Uri uri) in Microsoft.Graphics.Canvas.Interop.dll:token 0x6001c41+0x1a
   at Microsoft.Maui.FontManager.FindFontFamilyName(String fontFile) in Microsoft.Maui.dll:token 0x60000e0+0x3a
Microsoft.Maui.FontManager: Error: Error loading font 'ms-appx:///Assets/OpenSans-Regular.ttf'.

But even when I remove the fonts I still have the same behavior so I don't think this is related.

Any idea what could I be missing ?

sinsedrix commented 3 years ago

@Davidoutz I have the same issue. Did you manage to fix it?

Davidoutz commented 3 years ago

@sinsedrix unfortunately not yet. But somewhat I am happy to see that I am not the only one :)

mogand commented 3 years ago

I have the same issue

Fma965 commented 3 years ago

I'm on windows 11 but have the same issue also. image

ziaulhasanhamim commented 3 years ago

Have anyone fixed this problem. is it a problem with maui or winui 3 itself.

martin-juul commented 3 years ago

To make the fonts load correctly, you have to rename the fontFamily.

Go to Startup.cs and change these lines to fix it:

    .ConfigureFonts(fonts => {
        fonts.AddFont("fa-solid-900.ttf", "FontAwesome");
-       fonts.AddFont("OpenSans-Regular.ttf", "OpenSans-Regular");
+       fonts.AddFont("OpenSans-Regular.ttf", "Open Sans Regular");
-       fonts.AddFont("OpenSans-SemiBold.ttf", "OpenSans-SemiBold");
+       fonts.AddFont("OpenSans-SemiBold.ttf", "Open Sans SemiBold");
    })

A similar issue was confusing many of us with react-native-windows. See microsoft/react-native-windows/issues/652 for reference.