title: Handle an exception thrown from ctor with ImportingConstructor
body: <p>Here below are two classes where one of them is importing another one using ImportingConstructor and throws an MyException right from ctor. So, I expect to catch MyException in another class, but I get quite another one, namely:</p>
  
  <pre><code> System.InvalidOperationException: GetExportedValue cannot be called before prerequisite import 'Class1..ctor ' has been set. (...)
  </code></pre>
  
  <p>How can I force the MEF to throw an original exception, or at least to wrap original one to some exception, so I could to handle it from my code?</p>
  
  <pre><code>[Export]
  class Class1
  {
      public Class1()
      {
         (....)
         throw new MyException("MyException has been thrown");
      }
  }
  
  class Class2
  {
      [ImportingConstructor]
      public Class2(Class1 class1)
      {
          (....)
      }
  }
  
  static void Main(string[] args)
  {
      var catalog = new AggregateCatalog(
          new AssemblyCatalog(typeof (Class1).Assembly));
      CompositionContainer container = new CompositionContainer(catalog, true);
      try{
        Class2 class2 = container.GetExportedValue&lt;Class2&gt;();
      }
      catch(MyException ex){...}
  }
  </code></pre>