Appdomains and mixed mode assembly

  • Thread starter Thread starter Boni
  • Start date Start date
B

Boni

Dear all,
I have a global variable in the native code.
I was assuming that I create a IJW CLI wrapper class and create an instance
of this class in other appdomain, then the global variables will not be
shared between to. But it is apparently not the case.
Any ideas how I could separate the globals, when 2 instanes of native code
must run in parallel.
Thanks a lot,
Boni
 
Boni said:
Dear all,
I have a global variable in the native code.
I was assuming that I create a IJW CLI wrapper class and create an
instance of this class in other appdomain, then the global variables
will not be shared between to. But it is apparently not the case.
Any ideas how I could separate the globals, when 2 instanes of native
code must run in parallel.

They have to be non-global. Static variables in managed code are allocated
in special per-appdomain sections that are replicated for each new
appdomain. Not so for native static variables.

-cd
 
Hi Carl,
They have to be non-global. Static variables in managed code are
allocated in special per-appdomain sections that are replicated for each
new appdomain. Not so for native static variables.
Unfortunately I have no control above native code, I must just wrap it and
let it start from managed code. And this native code has many statics.
So it seems that only work around is to start multiple processes instead of
app domains. Also drawbacks are big.
Thanks a lot,
Boni
 
"Carl Daniel [VC++ MVP]" <[email protected]>
wrote in message | Boni wrote:
| > Dear all,
| > I have a global variable in the native code.
| > I was assuming that I create a IJW CLI wrapper class and create an
| > instance of this class in other appdomain, then the global variables
| > will not be shared between to. But it is apparently not the case.
| > Any ideas how I could separate the globals, when 2 instanes of native
| > code must run in parallel.
|
| They have to be non-global. Static variables in managed code are
allocated
| in special per-appdomain sections that are replicated for each new
| appdomain. Not so for native static variables.
|
| -cd
|

True for pure managed assemblies but not for native code global statics,
these have process scope not domain scope.

Willy.
|
 
Willy, I got it already. What is the solution?
How can I create a class instance in separate process?
 
Remoting , DCOM etc... . But why don't you try to get rid of this global
variable?

Willy.


| Willy, I got it already. What is the solution?
| How can I create a class instance in separate process?
Newsbeitrag
| | >
| > "Carl Daniel [VC++ MVP]"
<[email protected]>
| > wrote in message | > | Boni wrote:
| > | > Dear all,
| > | > I have a global variable in the native code.
| > | > I was assuming that I create a IJW CLI wrapper class and create an
| > | > instance of this class in other appdomain, then the global variables
| > | > will not be shared between to. But it is apparently not the case.
| > | > Any ideas how I could separate the globals, when 2 instanes of
native
| > | > code must run in parallel.
| > |
| > | They have to be non-global. Static variables in managed code are
| > allocated
| > | in special per-appdomain sections that are replicated for each new
| > | appdomain. Not so for native static variables.
| > |
| > | -cd
| > |
| >
| > True for pure managed assemblies but not for native code global statics,
| > these have process scope not domain scope.
| >
| > Willy.
| > |
| >
| >
|
|
 
Hi Willy,
First of all thanks a lot.
The libruary is not from me, and it can't be changed (unfortunately).
Do you know a good starting resource on remoting, DCOM etc?
BTW will remoting work on mixed mode assemblies? AFAIK it will fail, because
native stuff can't be sent over remoting.
Am I right?
 
Willy said:
"Carl Daniel [VC++ MVP]"
They have to be non-global. Static variables in managed code are
allocated in special per-appdomain sections that are replicated for
each new appdomain. Not so for native static variables.

True for pure managed assemblies but not for native code global
statics, these have process scope not domain scope.

I'm not sure what you were trying to add with this reply. It looks to me
like you merely repeated what I said. Is there some other subtlety you were
trying to clarify?

-cd
 
Back
Top