While writing this question: AppDomain, handling the exceptions I also thought of a different question.
If you would write a plugin app like I wrote above. Would you go about writing the plugins as executables or as libraries?
How much control would you have over a dynamically loaded executable that is run through the AppDomain.ExecuteAssembly(String)
method? instead of creating an instance of an object using AppDomain.CreateInstanceAndUnwrap(String, String)
.
Where I currently have an interface which features a Start/Run + Stop + Init method that is called after CreateInstanceAndUnwrap
. Would you have the same type of control over the executed assembly version? If I would use the latter, how can I achieve such functionality to dynamically stop that plugin?
Or am I thinking in the totally wrong direction?
[edit-after-question]
Basicly we got 'one' application, and multiple functions.
- Burning a (video) DVD)
- Printing photo's
- downloading images from a photo/videocamera
- a POS
- a storage server, functioning as a backup/configsettings/image+video repository
- displaying said photos/videos on a multiple displays
- and a few others, but these were the main 'functions'
A computer can run multiple tasks/plugins. For instance, we can choose to have one computer handle the whole image download/display/print system. Or have one centralized printing computer with multiple download/display systems.
Everything is communicating over sockets
If a plugin crashes for whatever reason it needs to be restarted and a mail should be send to the office. If the same crash occurs multiple times in a short timeframe then it should send some kind of emergency e-mail and shutdown that plugin and notify the operator.
Some of these functions use thirdparty unmanaged code, some are written in C++/Native and some in C++/CLI others are written in C#, all will be written within the same solution as different projects.
edit2 There is also this additional feature we would like to add to the system. It is to automatically update a plugin as soon as there is a newer version of that plugin available. The parent AppDomain/thread should periodically check for updates and if an update is found it should unload that plugin, download the new version and start it again. For this specific reason I think we need to use AppDomain's