title: SEHException not caught by Try/Catch
body: <p>In a background thread, my application regularly examines a network folder (UNC Path) for application updates. It reads out the assembly version of the file, like so:</p>
  
  <pre><code>Try
      newVers = System.Reflection.AssemblyName.GetAssemblyName("\\server\app.exe").Version
  Catch ex As Exception
      ' ignore
  End Try
  </code></pre>
  
  <p>This snippet is executed quite often, in total I'd guess way more than 100.000 times on multiple customer sites so far without a problem.  </p>
  
  <p>Sometimes, <code>GetAssemblyName</code> raises a <code>FileNotFoundException</code>, for instance in case the network folder is not reachable (which can happen and must be dealt with).  This exception is caught by the <code>Catch</code> block just below, and everything works just fine.</p>
  
  <p>In three reported cases, however, the <code>GetAssemblyName</code> call raised an <code>SEHException</code>.  The strange thing is that this exception was not caught by the <code>Catch</code> block just below, but by my global unhandled exception handler (<code>System.AppDomain.CurrentDomain.UnhandledException</code>).  As a result, the application crashes.</p>
  
  <p>Here is the exception detail (unfortunately, the <code>ErrorCode</code> and <code>CanResume</code> fields of the exception are not logged by my error handling routine):</p>
  
  <pre><code>Caught exception: System.Runtime.InteropServices.SEHException
     Message: External component has thrown an exception.
     Source: mscorlib
     TargetSite: System.Reflection.AssemblyName nGetFileInformation(System.String)
     StackTrace: 
        at System.Reflection.AssemblyName.nGetFileInformation(String s)
        at System.Reflection.AssemblyName.GetAssemblyName(String assemblyFile)
        at SyncThread.Run() 
        at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
        at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
        at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
        at System.Threading.ThreadHelper.ThreadStart()
  </code></pre>
  
  <p>Why is is that the exception is not caught by the <code>Catch</code> block just below?</p>
  
  <p>(Maybe this is relevant: this has only happened on customer sites, where the UNC path pointed to a server that was not part of the local network, but a remote server on a VPN.)</p>