title: Checking the type of an inner exception
body: <p>In my code I'm coming across a situation in which a <code>System.Reflection.TargetInvocationException</code> is thrown. In one specific case I know how I want to handle the root exception, but I want to throw all other exceptions. I can think of two ways of doing this, but I'm not sure which is better.</p>
  
  <p>1.</p>
  
  <pre><code>try
  {
      //code
  }
  catch (System.Reflection.TargetInvocationException ex)
  {
      if (typeof(ex.InnerException) == typeof(SpecificException))
      {
          //fix
      }
      else
      {
          throw ex.Innerexception;
      }
  }
  </code></pre>
  
  <p>2.</p>
  
  <pre><code>try
  {
      //code
  }
  catch (System.Reflection.TargetInvocationException ex)
  {
      try
      {
          throw ex.InnerException;
      }
      catch (SpecificException exSpecific)
      {
          //fix
      }
  }
  </code></pre>
  
  <p>I'm aware that throwing exceptions in general is slow, so I feel the first method would possibly be faster. Alternatively, is there a better way of doing this that I haven't thought of?</p>