[Mono-list] Event raised from Plugin class loaded at runtime in a different AppDomain using assemblyloader

Robert Jordan robertj at gmx.net
Tue Apr 13 05:51:45 EDT 2010


On 13.04.2010 11:14, Armando B. wrote:
>
> Hi all,
>
> i trying to generate an event from a plugin object that is created by an
> assembly loaded at runtime using an AssemblyLoader:
>
> Main AppDomain
> -PluginManager
>
> New AppDomain
> -AssemblyLoader (created using CreateInstanceAndUnwrap)
> -Plugin (created by AssemblyLoader using Activator.CreateInstance)
>
> i also override InitializeLifetimeService in AssemblyLoader and Plugin and
> all work fine if i call methods of my IPlugin from PluginManager. If Plugin
> raise an event in first minutes after load, also event raising is ok, but if
> i wait some minutes to raise event from Plugin, i receive en exception:
>
> Unhandled Exception: System.Runtime.Remoting.RemotingException: No receiver
> for uri ...
>
> i founded a workaround using a Ping event raised each 30 sec from Plugin to
> AssemblyLoader and so to PluginManager.

If your code is raising .NET events, you must take care of the
event handler's lifetime as well, i.e. if the event handler
is implemented by a MarshalByRefObject class, objects
of that class must be kept alive using InitializeLifetimeService.

Robert



More information about the Mono-list mailing list