I have a C# program that uses a class from another assembly, and this class calls an unmanaged DLL to do some processing. Here is a snippet:
public class Util { const string dllName = 'unmanaged.dll'; [DllImport(dllName, EntryPoint = 'ExFunc')] unsafe static extern bool ExFunc(StringBuilder path, uint field); public bool Func(string path, uint field) { return ExFunc(new StringBuilder(path), field); } ... } Util util = new Util(); bool val = util.Func('/path/to/something/', 1);
The problem I’m having is that if I call ‘Func’ my main C# program will not unload. When I call Close() inside my main form the process will still be there if I look in Task Manager. If I remove the call to ‘Func’ the program unloads fine. I have done some testing and the programs Main function definitely returns so I’m not sure what’s going on here.
Do you have the source code to
unmanaged.dll? It must be doing something, either starting another thread and not exiting, or blocking in it’sDllMain, etc.