I have a C# application that needs to use a legacy Win32 DLL. The DLL is almost its own application, it has dialogs, operations with hardware, etc. When this DLL is imported and used, there are a couple of problems that occur:
- Dragging a dialog (not a Windows system dialog, but one created by the DLL) across the managed code application causes the UI to not repaint. Further it generates a system out of memory exception from various UI controls.
- The performance is incredibly slow.
- There seems to be no way to unload the DLL so the memory never gets cleaned up. When we close our managed application, we get another memory exception.
At the moment we import each method call as such:
[DllImport("dllname.dll",
EntryPoint = "MethodName", SetLastError = true,
CharSet = CharSet.Auto, ExactSpelling = true,
CallingConvention = CallingConvention.StdCall)]