I have setup a secondary appDomain to host addins/plugins. The secondary AppDomain contains a loader method which loads the addin assembly using Assembly.LoadFrom(). The loader method then creates an object of the desired type ( the base class of the addin type ) by calling Invoke().
The addin type is derived from MarshalByRefObject.
After all this, I can access the plugin object via a remoting transparent proxy (TP).
Within the plugin there is an array object ( also derived from MarshalByRefObject ) which I need to access from the primary/application appdomain. I find that when I access the array from the primary appdomain (via the TP), it takes approx. 1,000 times longer than directly accessing the array from within the addin.
I thought there was going to be a performance penalty going through the TP, but did not expect this!
Is this to be expected Is there anyway to create a subdomain the primary appdomain so that I can get a reference to the array object ( or the addin object )
Thanks in advance!

Cross AppDomain Performance
Heinz09
OK, I see. Thanks a lot anyway.
Regards
ximadyn
Hello Todd,
What exactly do you mean by accessing the array Accessing one single item in it
or an iteration through the whole array
If you iterate through the whole array then i guess the time penalty that
you get will be proportional to the size of the array (it makes sense, right ).
And... I've found your post because I think you work on a very similar
architectural design (a main application which supports some plugins).
So I think you have many application domains in one single exe process.
The different app domains are used in order for you to have
isolation between the different plugins. Is that so in your case (in mine it is so)
I have one huge problem related to this architecture and I describe it here:
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=897805&SiteID=1
If you have any idea or if you've ever had a similar problem I will
be thankful if you let me know.
Regards
LPlate
Hi,
I solved the problem by having the plugin render to it's own window. The plugin window is a child window within a specially created host window ( based on IWin32Window ) located in the main appdomain application frame ( you have to use the Win32 API to get it to work ).
This way the plugin is isolated in its own appdomain, but its output window is hosted in a special main appdomain window.
I originally moved the rendering engine from the plugin appdomain to the main appdomain since a Forms.Control cannot be marshalled/remoted between appdomains! With the rendering engine in the main appdomain access to the plugin state was too slow! Thus the hosting window within the main appdomain.
Cheers, Todd
VooDoo Chicken
Hi again Todd. I see how you solved it. So actually transferring the data necessary for
the rendering from the plugin domain to the main app domain was the performance
bottleneck so you decided to do all the rendering in the plugin domain instead
using a special parent window created in the main domain.
Sorry to ask a second time but ... Have you ever had a problem that objects created
in your plugin app domains just don't get renewed by sponsors living in the main app domain.
Or you just didn't use sponsors in the main app domain for the objects/leases created in the
plugin app domains How did you manage the lifetime of the remote objects from the plugin
app domains Did you just specify infinite lifetime for these objects
In our application we have the load/unload feature which can at runtime load/unload a whole
"plugin directory/folder" and instantiate the appropriate objects (in our app they are subclasses
of 2 base classes called "Server" and "Job"). For that reason I don't want to specify
infinite lifetime for the remote objects instantiated in the plugin domains. Instead I use
one sponsor in the main app domain per one plugin app domain. So this sponsor is
sponsoring all remote objects from that plugin domain. Unfortunately at some point of time
the sponsor's Renewal() method just stops being called and I cannot figure out why.
Will be happy with any ideas from your side. I am almost ready to bet that you've had similar
issues as mine at some point of time (unless you used infinite lifetime, as said).
As I mentioned already a full description of my problem can be found here:
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=897805&SiteID=1
Give it a look if you have the time. Thanks in advance.
Regards.
Palmi
Sorry, I can't help you out!
My plugin objects are treated like open documents - they live until the user/application closes the document.
Cheers, Todd