Click here to Skip to main content
13,139,569 members (50,722 online)
Rate this:
Please Sign up or sign in to vote.
See more:

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?
Posted 24-Apr-12 22:23pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170915.1 | Last Updated 25 Apr 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100