title: DLL runtime error crashes my c# app - how to avoid it?
body: <p>Within my windows app, i'm using a c++ DLL wrapped with a .NET DLLs (specifically - the quickfix engine).
  While running, once every day (not at any specific time), in one of the a constructor of one of the built-in classes throws a runtime error.
  Even though the error is caught and reported (to a log file, and the database), I still get the windows 'runtime error' dialog (which offers no recovery/debugging options) and after pressing the 'ok' button (the only one available) my app is terminated.</p>
  
  <p>This happens when running in Debug, Release and even while running within the VS2005 debugger itself.</p>
  
  <p>As a side-note, I have compiled the above-mentioned DLLs locally (since at least one of them includes auto-generated code based on an XML specification).</p>
  
  <p>Anyone? (details follow)</p>
  
  <p>My code:</p>
  
  <pre><code>try
  {
      QuickFix.Symbol Symbol = new QuickFix.Symbol();
      report.get(Symbol);
      PairsType instrument = ToPairType(Symbol.getValue());
  
      if (PairsType.NONE == instrument)
          return;
  
      QuickFix.MDEntryDate entryDate = new MDEntryDate();
      QuickFix.MDEntryTime entryTime = new MDEntryTime();
      QuickFix.QuoteCondition quoteCondition = new QuoteCondition();
      QuickFix.MDEntryPx MDEntryPxBid = new QuickFix.MDEntryPx();
      QuickFix.MDEntryPx MDEntryPxAsk = new QuickFix.MDEntryPx();
  
      QuickFix.NoMDEntries noMDEntries = new QuickFix.NoMDEntries();
      report.get(noMDEntries);
  
      for (uint i = 1; i &lt;= noMDEntries.getValue(); ++i)
      {
          QuickFix44.MarketDataSnapshotFullRefresh.NoMDEntries group =
             new QuickFix44.MarketDataSnapshotFullRefresh.NoMDEntries();
  
          report.getGroup(i, group);
  
          if (group.isSetQuoteCondition())
              group.get(quoteCondition);
          if (group.isSetMDEntryDate())
              group.get(entryDate);
          if (group.isSetMDEntryTime())
              group.get(entryTime);
  
          switch (group.getMDEntryType().getValue())
          {
              case MDEntryType.BID:
                  group.get(MDEntryPxBid);
                  break;
              case MDEntryType.OFFER:
                  group.get(MDEntryPxAsk);
                  break;
          }
      }
  
      // use data...
  }
  catch (Exception e)
  {
      // log the error
  }
  </code></pre>
  
  <p>Error details:
  Message: External component has thrown an exception
  Stack trace:</p>
  
  <pre><code>at FIX.message_order.=(message_order* , message_order* )
   at std._Tree_nod&lt;std::_Tmap_traits&lt;int,FIX::FieldBase,FIX::message_order,std::allocator&lt;std::pair&lt;int const ,FIX::FieldBase&gt; &gt;,1&gt; &gt;.{ctor}(_Tree_nod&lt;std::_Tmap_traits&lt;int\,FIX::FieldBase\,FIX::message_order\,std::allocator&lt;std::pair&lt;int const \,FIX::FieldBase&gt; &gt;\,1&gt; &gt;* , message_order* _Parg, allocator&lt;std::pair&lt;int const \,FIX::FieldBase&gt; &gt;* _Al)
   at std._Tree&lt;std::_Tmap_traits&lt;int,FIX::FieldBase,FIX::message_order,std::allocator&lt;std::pair&lt;int const ,FIX::FieldBase&gt; &gt;,1&gt; &gt;.{ctor}(_Tree&lt;std::_Tmap_traits&lt;int\,FIX::FieldBase\,FIX::message_order\,std::allocator&lt;std::pair&lt;int const \,FIX::FieldBase&gt; &gt;\,1&gt; &gt;* , message_order* _Parg, allocator&lt;std::pair&lt;int const \,FIX::FieldBase&gt; &gt;* _Al)
   at FIX.FieldMap.{ctor}(FieldMap* , Int32* order)
   at QuickFix.Group..ctor(Int32 field, Int32 delim, Int32[] message_order)
   at QuickFix44.MarketDataSnapshotFullRefresh.NoMDEntries..ctor()
   at PriceProviders.PriceProvider.onMarketDataRefresh(FixSession session, MarketDataSnapshotFullRefresh report)
  </code></pre>