Catching Assembly Resolution Errors
<p>I am trying to do the following:</p>

<pre><code>m_appDomain = AppDomain.CreateDomain("Plugin AppDomain", null, new AppDomainSetup {PrivateBinPath = PluginActivator.SandboxFolder, PrivateBinPathProbe = "x"});    
PluginActivator activator = m_appDomain.CreateInstanceAndUnwrap(typeof(PluginActivator).Assembly.GetName().Name, typeof(PluginActivator).FullName) as PluginActivator;    
</code></pre>

<p>However, since the <code>PrivateBinPathProbe</code> is set to true, the second line does not look in the application base at all, and immediately crashes (<code>FileNotFoundException</code> on the executable that is running the code above).</p>

<p>I tried attaching an <code>AssemblyResolve</code> handler before the second line:</p>

<pre><code>m_appDomain.AssemblyResolve += OnAssemblyResolve;
</code></pre>

<p>The intention was to make the <code>AssemblyResolve</code> handler go into the <code>ApplicationBase</code> manually and load all the assemblies needed. This caused the application to crash with the same error.</p>

<p>I cannot change the order in which the directories are probed. How do I get around this problem?</p>

<p><strong>EDIT:</strong></p>

<p>I know this question isn't very clear, but I'm having trouble understanding what is the problem, so it's hard to be clearer. To begin with I do not understand why the new AppDomain I just created would even need a reference to the application executable.
If you would like me to clarify anything please let me know.</p>
