Wanting to do a project using OpenGL in C# with .NET 6 I made bindings to some functions in kernel32.dll, user32.dll, gdi32.dll and opengl32.dll on my main machine.
Everything works fine, I can open a window, initialize an OpenGL context and do some drawing, great.
Until I tried to run it on another computer where I can open a window, initialize an OpenGL context, but calling the bindings to OpenGL's functions will crash.
First, I thought that it there was some problem in my code so I wrote the equivalent program in C++ which worked fine.
Back to C#, I tried using Win32's LoadLibrary and GetProcAddress to see if I would get a null pointer when querying for glGetString, which ened up not being the case.
However, when calling to the delegate given by Marshal.GetDelegateForFunctionPointer I got a crash again.
This is kind a weird problem as there is no exception thrown, which should mean that the bindings are done successfully, but when looking up with a watch, in the debugger, the address of the OpenGL function the target is null.
Also, I checked in the imports using ildasm and JetBrain's DotPeek, opengl32.dll was there.
To finish, when crashing the exit code is 0xc0000374.
The repro is quite long, so here is a pastebin link.
And here is the cpp equivalent, which works; built with this batch file.
Starting to wonder if this is a .NET bug...
