falahati / WindowsDisplayAPI

WindowsDisplayAPI is a .Net wrapper for Windows Display and Windows CCD APIs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DeviceContext: Enable All results in Exception

1knueller opened this issue · comments

Trying this awesome package I stumbled over an error. I thought I report it here.

I use nuget package version 1.3.0.13. Im on win10 and run a winforms project with creating a "console build". i use vs 2019 and .net framework 4.7.2.

I start the programm just like in the example and things work but when i try the DeviceContext: Enable All option an exception occurs

console: ModeChangeException - Error: [Failed]: Applying saved settings failed.

visual studio output: Exception thrown: 'WindowsDisplayAPI.Exceptions.ModeChangeException' in WindowsDisplayAPI.dll

stacktrace from exception from debugger:

at WindowsDisplayAPI.DisplaySetting.Save(DisplayDevice display, Boolean reset)
at WindowsDisplayAPI.UnAttachedDisplay.Enable(DisplaySetting displaySetting, Boolean apply)
at WindowsDisplaySample.Program2.<>c.b__0_4() in F:\src\kwm\kwm\exaples.cs:line 117
at WindowsDisplaySample.ConsoleNavigation.<>c__DisplayClass0_0.b__0(Object index) in F:\src\kwm\kwm\exaples.cs:line 339
at WindowsDisplaySample.ConsoleNavigation.PrintObject[T](T[] objects, Action`1 action, String title, String message) in F:\src\kwm\kwm\exaples.cs:line 391

           i swapped these lines around in the example code resulting in this:

            startPosition += validSetting.Resolution.Width;
            display.Enable(placedSettings, true);

i also made a pull request