Shared Variables

  • Thread starter Thread starter John Bowman
  • Start date Start date
J

John Bowman

Hello,

Is there any way using managed code (I'm using C#) to have a DLL assembly
that is loaded into 2 processes have a reference to an object variable such
that the variable is shared between the processes? I need to retrieve an
object variable in process 2 that is set by process 1 and make use of the
information in process2. Pretty much a shared memory scenario inside the DLL
where both processes are running on the same PC.

TIA,
 
Micheal,

Thanks for the response. Unfortunately, the intent here was to stay w/in
managed code and specifically not use Win32 API's. I tried a few things w/
remoting too. In my case the object that I need to pass accross from process
1 to process 2 is the application's main form object. I managed to get the
form object to go accross because I can see that process 2 has the form
object and it's name is correct. But when I try to access any of the
controls on the form object that is passed over, the runtime throws an
exception complaining that the ControlCollection object is not seializable.
Any more ideas based on that?

John
 
I'm quite sure you can't pass windows from one process to another. That'd
require support from the OS to pass windows around. There might be some kind
of hack, but this would be completely a Windows issue (try a win32 newsgroup
perhaps).

-Michael
MVP
 
John said:
Micheal,

Thanks for the response. Unfortunately, the intent here was to stay w/in
managed code and specifically not use Win32 API's. I tried a few things
w/ remoting too. In my case the object that I need to pass accross from
process 1 to process 2 is the application's main form object. I managed to
get the form object to go accross because I can see that process 2 has the
form
object and it's name is correct. But when I try to access any of the
controls on the form object that is passed over, the runtime throws an
exception complaining that the ControlCollection object is not
seializable. Any more ideas based on that?

John
It appears to me that you could design a serializable class that you can
pass to another process. What you need to pay attention to is that there
are features of the instances being serialized that you should not
serialize: events, object structures containing circular references. This
can be managed by designating events as non-serializable; for this you need
to program this in C# as VB.net does not implement the "field" attribute
target.
I hope this helps
 
Back
Top