Re: Cross-appdomain communication
- From: Bagger <Bagger@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 14 Jun 2005 21:51:01 -0700
Thanks for the reply. Let me see if I can understand this. Do I create this
class and interface as a separate assembly, which would then be loaded in
the new appdomain when I create it? If so, and if my application has a
reference to that assembly in order to get the interface type, then I can
create an object of type IAddIn. What I don't understand is, how can I use
that object to talk to the other appdomain? How do I even create an object
in that other appdomain to talk to? Sorry I'm asking so many questions, but
I'm still having a tough time getting my head around how remoting works.
Thanks.
"Douglas Purdy [MSFT]" wrote:
> public interface IAddIn {
>
> void WriteAppdomainName();
>
> }
>
> class MyClass : MarshalByRefObject, IAddIn {
>
> static void Main(string[] args) {
>
> new MyClass().WriteAppdomainName();
>
> AppDomain domain = AppDomain.CreateDomain("another_appdomain");
>
> string assembly = typeof(MyClass).Assembly.FullName;
>
> string type = typeof(MyClass).FullName;
>
> IAddIn remoteInstance =
> (IAddIn)domain.CreateInstanceAndUnwrap(assembly, type);
>
> remoteInstance.WriteAppdomainName();
>
> }
>
> public void WriteAppdomainName() {
>
> Console.WriteLine("WriteAppdomainName called in {0}",
> AppDomain.CurrentDomain.FriendlyName);
>
> }
>
> }
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
> OR if you wish to include a script sample in your post please add "Use of
> included script samples are subject to the terms specified at
> http://www.microsoft.com/info/cpyright.htm"
>
>
> "Bagger" <Bagger@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:029E1DCA-5A58-4D12-A018-4B7AFB341BC6@xxxxxxxxxxxxxxxx
> > Here's what I'm trying to do. I have an app that searches for plugins at
> > runtime. It does this by loading each assembly in the plugins folder and
> > checking to see if it implements the plugins interface. My problem is
> > that
> > while I want to create a list of plugins, I don't want those assemblies to
> > remain in memory since the user will likely only want to use a few of the
> > plugins.
> >
> > So, here's what I'm planning to do. I want to create a separate
> > appdomain,
> > and have a remotable object in that domain compile the list of plugins and
> > pass it back to my application. Then I can unload that appdomain and my
> > memory issue is solved. Unfortunately, I have zero experience with
> > remoting,
> > so I'm not sure how best to go about this. Most of the books cover
> > remoting
> > from the standpoint of communicating from one machine to another, and
> > having
> > a client and a server, etc. What I want to know is what is the best way
> > to
> > use remoting in my situation?
> >
> > Do I create a server class and a remotable object and then somehow run the
> > server within the new appdomain? Is there an easier way? As you can
> > tell,
> > I'm a bit confused about this, so any help would be greatly appreciated.
> > Thanks!
>
>
>
>
.
- References:
- Cross-appdomain communication
- From: Bagger
- Re: Cross-appdomain communication
- From: Douglas Purdy [MSFT]
- Cross-appdomain communication
- Prev by Date: Will my custom bidirectional socket channel continue to work on .net 2.0?
- Next by Date: Re: Authentication and security in .NET Remoting
- Previous by thread: Re: Cross-appdomain communication
- Next by thread: Webservice call over proxy withouth credentials (anonymous)
- Index(es):
Relevant Pages
|