diff --git a/src/Markup/Avalonia.Markup.Xaml/XamlIl/Runtime/XamlIlRuntimeHelpers.cs b/src/Markup/Avalonia.Markup.Xaml/XamlIl/Runtime/XamlIlRuntimeHelpers.cs index 307896f3ee..d7bdfa14d0 100644 --- a/src/Markup/Avalonia.Markup.Xaml/XamlIl/Runtime/XamlIlRuntimeHelpers.cs +++ b/src/Markup/Avalonia.Markup.Xaml/XamlIl/Runtime/XamlIlRuntimeHelpers.cs @@ -176,7 +176,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.Runtime public RootServiceProvider(INameScope nameScope) { _nameScope = nameScope; - _runtimePlatform = AvaloniaLocator.Current.GetRequiredService(); + _runtimePlatform = AvaloniaLocator.Current.GetService(); } public object GetService(Type serviceType) @@ -186,7 +186,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.Runtime if (serviceType == typeof(IAvaloniaXamlIlParentStackProvider)) return this; if (serviceType == typeof(IRuntimePlatform)) - return _runtimePlatform; + return _runtimePlatform ?? throw new KeyNotFoundException($"{nameof(IRuntimePlatform)} was not registered"); return null; }