diff --git a/TestApp/Program.cs b/TestApp/Program.cs index 346405e..13b88d6 100644 --- a/TestApp/Program.cs +++ b/TestApp/Program.cs @@ -86,7 +86,12 @@ namespace TestApp if (_Driver is null || !_Driver.GetType().Equals(driverType)) { - var newDriverObject = Activator.CreateInstance(driverType); + var newDriverConstructor = driverType.GetConstructor(Array.Empty()); + if (newDriverConstructor is null) { + throw new InvalidOperationException($"Type {driverType} does not have a parameterless constructor!"); + } + + var newDriverObject = newDriverConstructor.Invoke(null, Array.Empty()); if (newDriverObject is null) { throw new InvalidOperationException("Could not instantiate driver!");