title: Exception not being catched
body: <p>In my MVC 5 application, I have this code: </p>
  
  <pre><code>try
  {
      var inputFile = new MediaFile { Filename = videoPath };
      var outputFile = new MediaFile { Filename = Config.ThumbPath };
  
      using (var engine = new Engine())
      {
          engine.GetMetadata(inputFile);
  
          if (inputFile.Metadata != null &amp;&amp; inputFile.Metadata.Duration.TotalSeconds &gt; 0)
          {
              var options = new ConversionOptions { Seek = TimeSpan.FromSeconds(inputFile.Metadata.Duration.TotalSeconds / 2) };
              engine.GetThumbnail(inputFile, outputFile, options);
  
              byte[] imageArray = System.IO.File.ReadAllBytes(Config.ThumbPath);
              base64ImageRepresentation = "data:image/jpeg;base64," + Convert.ToBase64String(imageArray);
          }
      }
  
  }
  catch (Exception ex)
  { 
       if (!EventLog.SourceExists("MYAPP"))
             EventLog.CreateEventSource("MYAPP", "Application");
  
       EventLog.WriteEntry("MYAPP", "CACHED: " + ex.Message);
       EventLog.WriteEntry("MYAPP", "CACHED: " + ex.Message,EventLogEntryType.Warning,234);
  }
  </code></pre>
  
  <p>Line <code>engine.GetMetadata(inputFile);</code> throws this:   </p>
  
  <blockquote>
    <blockquote>
      <p>An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll</p>
    </blockquote>
  </blockquote>
  
  <p>It's in a library called MediaToolkit which I installed from NuGet.</p>
  
  <p>Why does my try catch doesnt catch this exception?</p>
  
  <p>The file it gets is corrupt and thats why it throws the error, but if that happens I just want to continue to the next file. But, instead, the application stops.</p>
  
  <p>There is no entry in event log for this, but there is another entry for source ASP.NET.</p>
  
  <pre><code>An unhandled exception occurred and the process was terminated.
  
  Application ID: /LM/W3SVC/2/ROOT
  
  Process ID: 7364
  
  Exception: System.FormatException
  
  Message: Input string was not in a correct format.
  
  StackTrace:    at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer&amp; number, NumberFormatInfo info, Boolean parseDecimal)
     at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
     at System.Convert.ToInt32(String value)
     at MediaToolkit.Util.RegexEngine.TestAudio(String data, EngineParameters engine)
     at MediaToolkit.Engine.&lt;&gt;c__DisplayClass9.&lt;FFmpegEngine&gt;b__5(Object sender, DataReceivedEventArgs received)
     at System.Diagnostics.Process.ErrorReadNotifyUser(String data)
     at System.Diagnostics.AsyncStreamReader.FlushMessageQueue()
     at System.Diagnostics.AsyncStreamReader.GetLinesFromStringBuilder()
     at System.Diagnostics.AsyncStreamReader.ReadBuffer(IAsyncResult ar)
     at System.IO.Stream.ReadWriteTask.InvokeAsyncCallback(Object completedTask)
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
     at System.IO.Stream.ReadWriteTask.System.Threading.Tasks.ITaskCompletionAction.Invoke(Task completingTask)
     at System.Threading.Tasks.Task.FinishContinuations()
     at System.Threading.Tasks.Task.FinishStageThree()
     at System.Threading.Tasks.Task.FinishStageTwo()
     at System.Threading.Tasks.Task.Finish(Boolean bUserDelegateExecuted)
     at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task&amp; currentTaskSlot)
     at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
     at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
     at System.Threading.ThreadPoolWorkQueue.Dispatch()
     at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
  </code></pre>