Question

I have WPF host app and AddIn is also WPF which returns UI as described below:

[link] http://msdn.microsoft.com/en-us/library/bb909849%28v=vs.110%29.aspx

I would like to know if it is even possible to activate WPF AddIn as external process:It looks like WPF add-ins have only been thought to be used with AppDomain isolation, which is just not good enough for our app. If AddIn crashes for any reason, we can't allow host to crash all the time. We want our host app to be running even if loaded AddIn crashes.

I know we can achieve this in System.AddIn by using following:

//Activate the selected AddInToken in a new 
//application domain with the Internet trust level.
Calculator CalcAddIn = selectedToken.Activate<Calculator>(new AddInProcess(), AddInSecurityLevel.fulltrust);

But I have WPF AddIns not System.AddIn because our AddIns have WPF UI components.

I can activate WPFAddIn in new app domain as follows:

//Activate the selected AddInToken in a new 
//application domain with the Internet trust level.
Calculator CalcAddIn = selectedToken.Activate<Calculator>(AddInSecurityLevel.Internet);

I could not get any any up-to-date information about handling this situation with WPF AddIns. Is there any possible example either how to activate WPF AddIn in a separate process or catch unhandled exceptions in host. Basically I can't allow host to die when addIn crash. I did follow following link but turned out thread is very old and there is no current information.

[link]http://social.msdn.microsoft.com/Forums/vstudio/en-US/3c8592f2-14a6-418b-ab11-6d18096aaa0c/systemaddin-addinprocess-and-wpf?forum=wpf

If I can handle exception in host that will be fine too. Let me explain my problem:

I have WPF Host "A". have WPF AddIn "B".

I have loaded AddIn "B" in Host "A". AddIn "B" is having a click button. When user clicks a button, event will be fired in AddIn "B". In that event no try catches available, and some null exception is thrown from that event. This unhandled exception causing my host (WPF app as well) to crash.

I am looking for a solution, where I can handle this exception in Host "A", unload the AddIn "B" and continue Host without any crash.

I have tried AddIn with AddInSecurityLevel.FullTrust as well as AddInSecurityLevel.Internet.

Any hints or example will be helpful.

Was it helpful?

Solution

I think following msdn magazine article clearly explains how to design fault tolerant plugging based applications where plugins are hosted in separate process. It has a sample too. In the sample, addins' exceptions are handled easily without impacting host application or other addins.

Build Fault-Tolerant Composite Applications in WPF http://msdn.microsoft.com/en-us/magazine/dn519924.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top