From 12167dfea9254e3c22b76f8eabac0cbb37ebda1e Mon Sep 17 00:00:00 2001 From: "M. ter Woord" Date: Mon, 21 Aug 2017 18:22:04 +0200 Subject: [PATCH] Show descriptive error when no rendering or windowing subsystem found --- src/Avalonia.DotNetFrameworkRuntime/AppBuilder.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.DotNetFrameworkRuntime/AppBuilder.cs b/src/Avalonia.DotNetFrameworkRuntime/AppBuilder.cs index 9a54cdbab0..bae97f503d 100644 --- a/src/Avalonia.DotNetFrameworkRuntime/AppBuilder.cs +++ b/src/Avalonia.DotNetFrameworkRuntime/AppBuilder.cs @@ -59,7 +59,11 @@ namespace Avalonia from attribute in assembly.GetCustomAttributes() where attribute.RequiredOS == os && CheckEnvironment(attribute.EnvironmentChecker) orderby attribute.Priority ascending - select attribute).First(); + select attribute).FirstOrDefault(); + if (windowingSubsystemAttribute == null) + { + throw new InvalidOperationException("No windowing subsystem found. Are you missing assembly references?"); + } var renderingSubsystemAttribute = (from assembly in RuntimePlatform.GetLoadedAssemblies() from attribute in assembly.GetCustomAttributes() @@ -67,7 +71,12 @@ namespace Avalonia where attribute.RequiresWindowingSubsystem == null || attribute.RequiresWindowingSubsystem == windowingSubsystemAttribute.Name orderby attribute.Priority ascending - select attribute).First(); + select attribute).FirstOrDefault(); + + if (renderingSubsystemAttribute == null) + { + throw new InvalidOperationException("No rendering subsystem found. Are you missing assembly references?"); + } UseWindowingSubsystem(() => windowingSubsystemAttribute.InitializationType .GetRuntimeMethod(windowingSubsystemAttribute.InitializationMethod, Type.EmptyTypes).Invoke(null, null),