Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving data across the appdomain with good performance?

A little background

I'm working on an .net application that's uses plugins heavily, the application can request data from the plugins that is then sent back and displayed by the application.

First I implemented the plugin framework in MEF but feel that it was a bit limited for my purposes, I wanted to be able to isolate plugins and have some versioning and licensing support (since plugins can be written by thirdparty).

Then started looking at MAF which seems support just those scenarios, however I can see one thing that might be a problem, before I invest too much time changing everything to MAF it would be great knowing if someone has experience with this issue since I havent worked much with MAF.

The problem

Currently when data is sent back to the application you get the actual objects of the data along with an adapter that says which fields the object contains and you can use the adapter on the object to extract the fields you want. The good thing about this is that you don't have to generate any new results objects but can simply query the results data when you want it from each object.

Now with MAF there's the Appdomain issue, I can't freely send all the objects across the app domain and inheriting from marshalbyref for each object isn't viable.

I could generate a result object with the string fields for each object but from a performance standpoint it doesnt seem such a good idea, the interface might only show 10 of hundreds of objects so it seems smarter to do on demand.

The solution I'm thinking might work is generating a sequence of just object id's and let the interface fetch the fields from the plugin through the appdomain through a proxy. So the application says for instance it wants fieldname x from items [y] in the plugin and those strings is sent across the appdomain.

The Question

So my questions are, is this a good way to do it, is there a better way? I'm obviously going to take a little performance hit moving across the appdomain still but since it's on demand and only for a small number of objects it shouldn't be too bad right? How do I go about setting up a proxy object like that?

It's not the easiest question in the world to answer, sorry. I'll really appreciate any insight, the future of the plugin architecture depends on it :)

like image 268
Homde Avatar asked Sep 08 '10 14:09

Homde


People also ask

What is the difference between AppDomain assembly process and a thread?

A process is an executing application (waaaay oversimplified). A thread is an execution context. The operating system executes code within a thread. The operating system switches between threads, allowing each to execute in turn, thus giving the impression that multiple applications are running at the same time.

What is AppDomain and CurrentDomain?

The CurrentDomain property is used to obtain an AppDomain object that represents the current application domain. The FriendlyName property provides the name of the current application domain, which is then displayed at the command line.

What is AppDomain in .NET core?

The . NET runtime uses an AppDomain as a container for code and data, just like the operating system uses a process as a container for code and data. As the operating system uses a process to isolate misbehaving code, the . NET runtime uses an AppDomain to isolate code inside of a secure boundary.

What is the use of AppDomain in C#?

The AppDomain class implements a set of events that enable applications to respond when an assembly is loaded, when an application domain will be unloaded, or when an unhandled exception is thrown.


1 Answers

.NET Remoting is the fastest way to exchange information between code running in two appdomains within the same process. If your appdomains are running in two separate processes, use WCF to exchange binary over Named Pipes.

This paper (a more recent version of the one I originally wrote ;)) should answer questions about which comms mechanism to use for cross-process and cross-machine perf.

like image 104
Rich Turner Avatar answered Oct 19 '22 20:10

Rich Turner