I have an unmanaged DLL (written in C++) and going to call it from the managed code through the P/Invoke.
DLL implements a sort of "gateway" to the stock trading server and is written so that at first we should establish a connection to the required trading server (host, port, login, password, etc.) and then we can do some other operations (e.g. send trading orders).
The problem is that DLL is not reentrant at all by its design - there can only be a single connection (no connection IDs, etc. are used in further function calls - they all are implied to be done on that connection we have initially established). Looks like it keeps its current connection state in its static variables and use them later. Buy I need 2 connections to 2 different servers.
My question is - is it possible to load 2 "instances" of the same DLL to the same .NET process so they would have different sets of its internal static variables ("connection states")? Maybe if we create another AppDomain another instance of DLL will be loaded into it?
Or the only way out is to launch separate .NET processes - one per connection required?