title: AddIn (MAF) : Running in Separate process
body: <p>I have WPF host app and AddIn is also WPF which returns UI as described below:</p>
  
  <p>[link] <a href="http://msdn.microsoft.com/en-us/library/bb909849%28v=vs.110%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/bb909849%28v=vs.110%29.aspx</a></p>
  
  <p>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. </p>
  
  <p>I know we can achieve this in <code>System.AddIn</code> by using following:</p>
  
  <pre><code>//Activate the selected AddInToken in a new 
  //application domain with the Internet trust level.
  Calculator CalcAddIn = selectedToken.Activate&lt;Calculator&gt;(new AddInProcess(), AddInSecurityLevel.fulltrust);
  </code></pre>
  
  <p>But I have WPF AddIns not <code>System.AddIn</code> because our AddIns have WPF UI components.</p>
  
  <p>I can activate WPFAddIn in new app domain as follows:</p>
  
  <pre><code>//Activate the selected AddInToken in a new 
  //application domain with the Internet trust level.
  Calculator CalcAddIn = selectedToken.Activate&lt;Calculator&gt;(AddInSecurityLevel.Internet);
  </code></pre>
  
  <p>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.</p>
  
  <p>[link]<a href="http://social.msdn.microsoft.com/Forums/vstudio/en-US/3c8592f2-14a6-418b-ab11-6d18096aaa0c/systemaddin-addinprocess-and-wpf?forum=wpf" rel="nofollow">http://social.msdn.microsoft.com/Forums/vstudio/en-US/3c8592f2-14a6-418b-ab11-6d18096aaa0c/systemaddin-addinprocess-and-wpf?forum=wpf</a></p>
  
  <p>If I can handle exception in host that will be fine too. Let me explain my problem:</p>
  
  <p>I have WPF Host "A". have WPF AddIn "B".</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>I have tried AddIn with <code>AddInSecurityLevel.FullTrust</code> as well as  <code>AddInSecurityLevel.Internet</code>.</p>
  
  <p>Any hints or example will be helpful.</p>