title: The runtime has encountered a fatal error
body: <blockquote>
    <p>The runtime has encountered a fatal error. The address of the error
    0x6a0a7c6d on thread 0x1f70. The error code is 0x80131623. This may be
    a bug in the CLR or in the unsafe or non-verifiable portions of user
    code. Often the source of this error formed by marshal user errors for
    COM-interop or PInvoke, which may damage the stack.</p>
  </blockquote>
  
  <p>Does anyone know how to track down this problem and what he actually mean?!</p>
  
  <p>the code where this happen is the following:</p>
  
  <pre><code>        Public Sub Ok()
  
              Try
                  BTWTariefID = 0
                  If Prijs &gt; 0 Then
                      Dim formVraagBtw As New wndVraagBTW()
                      formVraagBtw.ShowDialog()
                      BTWTariefID = formVraagBtw.BTWID
                  End If
  
                  CreateOpmerking(Nothing, False, BTWTariefID)
  
              Catch ex As Exception
                  WriteErrorLog("btnOk", New StackTrace().GetFrame(0).GetMethod.ToString(), ex)
              End Try
  
          End Sub
  </code></pre>
  
  <p>The odd thing in this is if i set a breakpoint inside this sub and then hit f5 i dont get any errors only if i dont have any breakpoints on this sub i will get the error.</p>
  
  <p>Any ideas?</p>
  
  <p>EDIT:</p>
  
  <pre><code>Private Sub CreateOpmerking(gRegel As clsVerkooporderRegel, showBTWTarief As Boolean, btwTariefID As Integer)
  
              Try
                  Dim dblPrijs As Double
                  If DMStr(Prijs).Trim = "" Then Prijs = "0"
                  If Opmerking.Length &gt; 0 And Double.TryParse(Prijs, dblPrijs) Then
  
                  Else
                      dblPrijs = 0
                  End If
  
                  If OrderRegel Is Nothing Then
                      If gRegel Is Nothing Then
                          Parent.VMVerkoop.opmerkingsregel(Opmerking, dblPrijs, Aantal, Item, Gang, showBTWTarief, btwTariefID)
                      Else
                          Parent.VMVerkoop.opmerkingsregel(Opmerking, dblPrijs, gRegel.aantal, gRegel.orderregel.item, gRegel.orderregel.Gang, showBTWTarief, btwTariefID)
                      End If
                      Me.Parent.ModalVisibility = Visibility.Hidden
                      Me.Parent.Modal = Nothing
                  Else
                      OrderRegel.orderregel.opmerking = Opmerking
                      OrderRegel.orderregel.Omschrijving2 = Opmerking
                      OrderRegel.orderregel.prijs_per_stuk = dblPrijs
                      OrderRegel.orderregel.prijs_per_stuk_origineel = dblPrijs
                      OrderRegel.orderregel.btwtariefID = btwTariefID
                      OrderRegel.orderregel.aantal = Aantal
                      If Artikel IsNot Nothing Then OrderRegel.orderregel.artikelID = Artikel.ID
                      OrderRegel.regeltotaalnakorting = Aantal * dblPrijs
                      'Me.Parent.VMVerkoop.opmerkingsregel(Opmerking, dblPrijs, Aantal, Item, Gang, Artikel)
                      Me.Parent.ModalVisibility = Visibility.Hidden
                      Me.Parent.Modal = Nothing
                      Me.Parent.VMVerkoop.ververs_orderregels()
                      Opmerking = ""
                  End If
              Catch ex As Exception
                  WriteErrorLog("CreateOpmerking", New StackTrace().GetFrame(0).GetMethod.ToString(), ex)
              End Try
          End Sub
  </code></pre>
  
  <p>The error happens when the if condition is true, but if i set a breakpoint even outside the if condition the code will run with no problems, if i take the breakpoint out there is not error at all.
  Thanks</p>