Communication between appdomains

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have the following situation:

2 appdomains that both use an assembly (DLL). There is important information
in this DLL which can be modified at runtime by either appdomains. What I
need is a mechanism so that I can notify one appdomain when the other has
made any changes.

How can I do this? .NET Events don't seem to cut it, and looking at
Richter's Programming Applications for MS Windows, 4th edition, the only
thing that looks like a possible solution is the use of a shared section with
a variable (although I suspect I would need to do this in C++), or memory
mapped files. Both of which I have 0 experience with, and would rather remain
within .NET territory.

Any help?
 
Hi

In .NET we use remoting to communicate between AppDomain.
Based on my understanding, you will create two appdomains and they will
load the same assembly dll.
I did not understanding your scenario very well, what do you mean by
"modify the information at runtime", how and what do you do that?
Can you describe it more clearly?

Here are some links about appdomain programming.
AppDomains ("application domains")
http://blogs.msdn.com/cbrumme/archive/2003/06/01/51466.aspx

Copying, Cloning, and Marshalling in .NET
http://www.ondotnet.com/pub/a/dotnet/2002/11/25/copying.html?page=3


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi and thanks. Let me rephrase my question:

How can I invoke a method that lies in a .NET DLL that is loaded by two
distinct AppDomains? See, I need to call the method when one of the
AppDomains makes a certain change that invalidates some data in the DLL.

Is this clearer?
 
Hi

So if you want to invoke the method, we need to tell the runtime in which
AppDomain you want to execute the method.
If a dll is loaded into two appdomain, we can consider there are two dll
copy in the memory, each appdomain own one.
If certain dll's method will create a new object, then we execute the
method in appdomain A, then the object will be created in appdomain A, if
we execute the method on Appdomain B, another object will be created on
appdomain B.

If now we change the object in Appdomain A, the Appdomain B's object will
not change.

We can consider the appdomain as a process in win32 category.
For how to call a method in certain appdomain from another appdomain, you
may refer to the links I post before.

Also can you tell us why you wants to do that? what is your concrete
scenario?

BTW I think you may try to take a look at the two books about process,dll,
thread, appdomain.
Programming Applications for Microsoft Windows (Dv-Mps General)
by Jeffrey Richter
http://www.amazon.com/exec/obidos/tg/sim-explorer/explore-items/-/1572319968
/0/101/1/none/purchase/ref%3Dpd%5Fsxp%5Fr0/103-8401450-8094224

Applied Microsoft .NET Framework Programming
by Jeffrey Richter
http://www.amazon.com/exec/obidos/ASIN/0735614229/qid=1120875040/sr=2-1/ref=
pd_bbs_b_2_1/103-8401450-8094224

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Thanks for your help. I finally found a way to do what I wanted. Basically I
synchronized via a file and used FileSystemWatcher.

Thanks again. Your comments were helpful!


Juan Dent, M.Sc.
 
Hi Juan,

I am glad that you have worked out the problem.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top