Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ .NET PInvoke
Hi!
 
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 23:23pm

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

  Print Answers RSS
0 Kornfeld Eliyahu Peter 275
1 Maciej Los 214
2 Sergey Alexandrovich Kryukov 200
3 King Fisher 185
4 OriginalGriff 163
0 OriginalGriff 6,223
1 DamithSL 4,724
2 Maciej Los 4,196
3 Kornfeld Eliyahu Peter 3,894
4 Sergey Alexandrovich Kryukov 3,496


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 25 Apr 2012
Copyright © CodeProject, 1999-2014
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