運行時遇到致命錯誤。線程0x1f70上的錯誤 0x6a0a7c6d的地址。錯誤代碼是0x80131623。這可能是 CLR中的錯誤或用戶代碼的不安全或不可驗證部分中的錯誤。通常,由編組用戶錯誤形成的此錯誤的來源可能會損壞堆棧,這些錯誤可能是由於COM-interop或PInvoke可能會導致 。運行時遇到致命錯誤
有沒有人知道如何找出這個問題,他究竟是什麼意思?
的代碼中出現這種情況如下:
Public Sub Ok()
Try
BTWTariefID = 0
If Prijs > 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
在這個奇怪的是,如果我設置此子中的斷點,然後按F5鍵我沒有得到任何錯誤,只要我沒有任何斷點在這個子我會得到錯誤。
任何想法?
編輯:
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 > 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
錯誤發生時,如果條件爲真,但如果我設置斷點外連,如果條件代碼將沒有問題跑,如果我把斷點外面有根本沒有錯誤。 感謝
代碼中的哪一行導致此錯誤? 「CreateOpmerking(Nothing,False,BTWTariefID)」是做什麼的? – Ric
編輯問題的詳細信息 – Rui
幾件事情 - 你幾乎不想捕捉基本的異常類型。這是最糟糕的做法。在錯誤日誌代碼中,您調用GetFrame來獲取方法名稱 - 在優化的代碼中,這可能無法按預期工作。我只需編寫整個異常.ToString()結果。 – asawyer