sskodje / ScreenRecorderLib

A .NET library for screen recording in Windows, using native Microsoft Media Foundation for realtime encoding to h264 video or PNG images.
MIT License
408 stars 93 forks source link

Win server 2016 - failing to load library #258

Closed pm4444 closed 1 year ago

pm4444 commented 1 year ago

On Windows Server 2016 I'm unable to load library. It crashes during load of class before it even gets to code to create recorder. Are there some known steps needed to take to make it run on Win Server 2016?

I tested same code (console app .net 4.6.2 built as x86 wrapping ScreenRecorderLib for 10s test video) on Windows Server 2019 and 2022 and it works on both. All Windows Servers are running as Hyper-V VMs and are new clean installations (updated).

On all 3 Windows Servers I installed Media foundation library and Visual C++ Redistributable x86 2015-2019.

I tried both x86 and x64 versions of library and both had same results. For x64 I of course installed C++ x64 and built app as x64. Tried to run it also with installed visual studio 2022, but it didn't make any change.

I tried dependency walker (older and also newer version), but frankly I'm not sure how to read results. In visual studio with turned flag to show dll load errors it shown error during loading of NTDLL.dll Dependency walker shows warnings for all visual c++ libraries, but it show same warnings on servers where application runs correctly. Dependencies (newer dependency walker) shows error loading SysWOW64/kernel32.dll, but when trying to load that library separately it show no error. As ScreenRecoredLib is not even loaded correctly there is no text log created.

In windows application log I get error Faulting module name: KERNELBASE.dll, version: 10.0.14393.1770, time stamp: 0x59bf2bcf Faulting module path: C:\Windows\System32\KERNELBASE.dll Exception code: 0xe0434352 Fault offset: 0x000daa12 Faulting process id: 0x2c8

sskodje commented 1 year ago

You were on the right track, it turned out to be a dependency error. Dependency walker is broken though. I had better luck with Dependencies. The problem turned out to be a function for setting thread descriptions not being available in Server 2016, sigh. I just removed it and it should work now.