I have a native dll that I wrapped in a dotnet6 libary. I am successfully loading my wrapper, and calling against that library using a simple dotnet6 WinForms app. I can see it is working and responding well. The native dll has it's own internal state machine, managing communication with a third party piece of hardware (via a COM port, supplied during loading).
When I create an instance of my wrapper in WinForms, everything works as expected. I have an event on the wrapper to let me know when it has completed a lengthy (~5 seconds) initialisation with the hardware it is talking to.
When I try to replicate that with a console application, it never makes the connection. I am logging timer ticks in the wrapper every second while it is trying to connect, but it doesn't ever connect. I am wondering if this is something to do with the way a WinForms app manages it's own objects that allows the native lib to execute in a way the console doesn't?
I have tried moving the creation and call into a background thread in the console app, but this has the same behaviour. Does anyone have any ideas on this?