You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Works fine on Windows. When I start the app on Macos (or probably any other platform) I get this ominous exception
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at Avalonia.Styling.Styles.TryGetResource(Object key, ThemeVariant theme, Object& value)
at Avalonia.Application.TryGetResource(Object key, ThemeVariant theme, Object& value)
at Avalonia.Controls.ResourceNodeExtensions.TryFindResource(IResourceHost control, Object key, ThemeVariant theme, Object& value)
at Avalonia.Controls.ResourceNodeExtensions.TryFindResource(IResourceHost control, Object key, Object& value)
at Avalonia.StyledElement.GetEffectiveTheme()
at Avalonia.StyledElement.ApplyControlTheme()
at Avalonia.StyledElement.ApplyStyling()
at Avalonia.StyledElement.EndInit()
at MyApp.Views.TestWindow.!XamlIlPopulate(IServiceProvider, TestWindow) in /Users/self/Documents/workspace/app/App/Views/TestWindow.axaml:line 7
at MyApp.Views.TestWindow.!XamlIlPopulateTrampoline(TestWindow)
at MyApp.Views.TestWindow.InitializeComponent(Boolean loadXaml, Boolean attachDevTools) in /Users/self/Documents/workspace/app/App/obj/Debug/net8.0/Avalonia.Generators/Avalonia.Generators.NameGenerator.AvaloniaNameSourceGenerator/MyApp.Views.TestWindow.g.cs:line 25
at MyApp.Views.TestWindow..ctor() in /Users/self/Documents/workspace/app/App/Views/TestWindow.axaml.cs:line 11
at MyApp.App.OnFrameworkInitializationCompleted() in /Users/self/Documents/workspace/app/App/App.axaml.cs:line 117
at Avalonia.AppBuilder.SetupUnsafe()
at Avalonia.AppBuilder.Setup()
at Avalonia.AppBuilder.SetupWithLifetime(IApplicationLifetime lifetime)
at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(AppBuilder builder, String[] args, Action`1 lifetimeBuilder)
at MyApp.Program.Main(String[] args) in /Users/self/Documents/workspace/app/App.Desktop/Program.cs:line 31
To Reproduce
Define in Application.Styles an OnPlatform element that doesn't match the current platform
Expected behavior
To do nothing when there's no match, or if this usage isn't allowed, to output a meaningful error that explains the mistake. I can add a default match with an unused style in it as a workaround.
Avalonia version
11.2.0
OS
Windows, macOS
Additional context
No response
The text was updated successfully, but these errors were encountered:
To do nothing when there's no match, or if this usage isn't allowed, to output a meaningful error that explains the mistake.
OnPlatform follows ternary operator logic. It always needs to return a value. In this case it's a null .
It's still expected to return null as a default in some contexts.
We should at least generate a diagnostic error, which can be optionally disabled.
Describe the bug
I'd written a style with an override for when the window is maximised in Windows:
Works fine on Windows. When I start the app on Macos (or probably any other platform) I get this ominous exception
To Reproduce
Define in Application.Styles an OnPlatform element that doesn't match the current platform
Expected behavior
To do nothing when there's no match, or if this usage isn't allowed, to output a meaningful error that explains the mistake. I can add a default match with an unused style in it as a workaround.
Avalonia version
11.2.0
OS
Windows, macOS
Additional context
No response
The text was updated successfully, but these errors were encountered: