In my scenario, I want to execute a method in a separate AppDomain. How many different ways could I take to achieve this?
Especially, I have the following question:
In order to execute code in a separate AppDomain, the assembly containing that code has to be loaded into that AppDomain. From there you can call a method in the second AppDomain from your hosting domain using reflection or the "CreateInstance" methods on the AppDomain class.
Keep in mind, AppDomains are hard boundaries. In order to communicate across the AppDomain boundaries, you will need to use remoting or a true IPC-ish mechanism.
This is a bit dated, but I believe it still applies. http://blogs.msdn.com/b/suzcook/archive/2003/06/12/57169.aspx
Suzanne Cook had a series of posts related to this subject so it may be worth browsing her archives a bit.
Check out the "CreateInstance" family of methods on the AppDomain class. In the past I've used CreateInstanceFromAndUnwrap() quite a bit for this type of situation.
As far as your question about how many ways there are to do this... Um, many, but it depends a lot on the exact situation and what objects you have in hand.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With