Browse Source

Show descriptive error when no rendering or windowing subsystem found

M. ter Woord 8 years ago
parent
commit
12167dfea9
1 changed files with 11 additions and 2 deletions
  1. 11 2
      src/Avalonia.DotNetFrameworkRuntime/AppBuilder.cs

+ 11 - 2
src/Avalonia.DotNetFrameworkRuntime/AppBuilder.cs

@@ -59,7 +59,11 @@ namespace Avalonia
                                                from attribute in assembly.GetCustomAttributes<ExportWindowingSubsystemAttribute>()
                                                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<ExportRenderingSubsystemAttribute>()
@@ -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),