title: C# Uncaught exception in unit test
body: <p>I'm encountering a very strange issue while debugging a unit test.  If I debug the unit test (ctrl+r ctrl+t) I am getting an uncaught exception.  If I just run the unit test (ctrl+r t) I do not get this exception.</p>
  
  <p>The uncaught exception is a <strong>NHibernate.ByteCode.ProxyFactoryFactoryNotConfiguredException.</strong></p>
  
  <p>Stack trace:  </p>
  
  <pre><code>at NHibernate.Bytecode.AbstractBytecodeProvider.get_ProxyFactoryFactory() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Bytecode\AbstractBytecodeProvider.cs:line 32
  at NHibernate.Validator.Util.NHibernateHelper.IsProxyFactoryConfigurated()
  </code></pre>
  
  <p>I used .Net Reflector to look at the assembly that defines this method (NHibernate.Validator ... it's open source) and here is the method that "throws" the exception:  </p>
  
  <pre><code>public static bool IsProxyFactoryConfigurated()
  {
      try
      {
          IProxyFactoryFactory proxyFactoryFactory = Environment.BytecodeProvider.ProxyFactoryFactory;
          return true;
      }
      catch (ProxyFactoryFactoryNotConfiguredException)
      {
          return false;
      }
  }
  </code></pre>
  
  <p>How can this exception not be caught by that Try Catch block?</p>