D DLL crashes if not run on the main thread
Hipreme
msnmancini at hotmail.com
Tue Sep 5 22:57:22 UTC 2023
On Tuesday, 5 September 2023 at 22:45:28 UTC, raven09 wrote:
> Hi,
> I've compiled a DLL using D and intended to use it with a C#
> winforms app using P/Invoke. Everything works wonderfully as
> long as it is called from the main thread (at least I assume
> that it not being on the main thread is causing the issues). If
> I start a new thread and try using any function imported from
> the DLL the program will instantly crash. Debugging the
> winforms app with VS shows that it does indeed crash on that
> function call, but does not provide any more information.
> Further testing I did was writing a test DLL that basically
> just contained `` extern(C) export int TestMe() { return 5; }``
> and calling it in a new C# program: it worked fine until I put
> it in a separate thread.
>
> [...]
Hi, maybe you could try putting your DLL load function inside the
thread which you're calling your function? Maybe there could be
something related to that.
More information about the Digitalmars-d-learn
mailing list