SharpHook: The method CreateScreenInfo is causing app crash
When trying to get the screen info using the managed version of UioHook.CreateScreenInfo() the app will randomly crash with a 3221226356 return code. That return code is usually for an access violation, buffer overflow, stack overflow, invalid pointer or interop issues.
It looks like it may be a problem with the native libuiohook lib as just calling UioHook.CreateScreenInfo(out byte count) will produce the same error.
Here is an example code that I was able to reproduce, keep in mind it’s random, and may need to be restarted a few times.
using SharpHook.Native;
Task.Run(async () =>
{
while (true)
{
var screenInfo = UioHook.CreateScreenInfo()
.OrderBy(x => x.Number)
.FirstOrDefault();
Console.WriteLine($"Screen: [Width: {screenInfo.Width}, Height: {screenInfo.Height}]");
await Task.Delay(50);
}
});
Console.ReadLine();
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 15 (8 by maintainers)
If you have 2 screens, you can add a mobile or tablet as a 3rd screen using the SpaceDesk app; that’s what I did.
https://www.spacedesk.net/
Windows 10 with 3 displays at 4k and 200% scale.