Re: Cross-appdomain communication



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!
>
>
>
>
.



Relevant Pages

  • Re: Cross-AppDomain call problems
    ... It might be that I pass a custom exception accross ... that I pass custom assemblies accross. ... none of the types are leaking across the appdomain boundary. ... I have a simple interface assembly that defines all the types the two ...
    (microsoft.public.dotnet.framework)
  • Cross-AppDomain calls and different assmbly versions
    ... in its own AppDomain to allow ... The interface reference to this object is passed to the tasks when ... assemblies, ... bind to the task's version of the SMTP component rather than the ...
    (microsoft.public.dotnet.framework.clr)
  • Cross-AppDomain remoting strangeness
    ... in its own AppDomain to allow ... The interface reference to this object is passed to the tasks when ... assemblies, ... bind to the task's version of the SMTP component rather than the ...
    (microsoft.public.dotnet.framework.remoting)
  • Cross-AppDomain call problems
    ... in its own AppDomain to allow ... The interface reference to this object is passed to the tasks when ... assemblies, ... bind to the task's version of the SMTP component rather than the ...
    (microsoft.public.dotnet.framework)
  • Re: References for designing a "Plug-In" software architecture
    ... doing an interface based plugin system is remarkably easy ... ... are the plugins to be local or do they need to be capable of being ... assemblies you told it to look in. ... private string m_Description; ...
    (microsoft.public.dotnet.languages.csharp)