I am currently fighting with calling an unmanaged C DLL from my C# Winforms application. Basicaly, it works, but sometimes it seems like the DLL looses its context, so I have to restart my app to be able to work with it again.Are there any rules when the unmanaged DLL is loaded and when released from memory during my app is running? Or can the garbage collector randomly release the DLL and then initialize it again when the DLL is called next time?I am using the standard approach to call DLL functions:[DllImport("Bat1Dll.dll")]public static extern uint GetDeviceVersion();
The DLL reads a block of data from a device connected via USB. The data is kept in the DLL, I can edit it using several functions and finaly send the data back to the device.Thanks for any suggestions,Petr