我得到一個錯誤:型「System.AccessViolationException」未處理的異常發生在System.DirectoryServices.dll程序
An unhandled exception of type 'System.AccessViolationException' occurred in System.DirectoryServices.dll
隨機地在移動用戶屈指可數。
奇怪的是,似乎沒有任何押韻或理由說明它們何時發生,我在TRY中試過,最近因爲某種原因它開始崩潰應用程序。在調試器中,它們彈出,您可以繼續完成它們並完成線程,「失敗」操作工作,並在下一個週期重新運行移動。
< --Code剪斷了 - >
If Action_Exe = "Update" Then
If IsDBNull(Processing_DataResults.Rows.Item(Master_Loop)(16)) Then
Trace.WriteLine("Error in datatable. NULL found.")
Trace.WriteLine("Record: " & Master_Loop)
Trace.WriteLine("User: " & Processing_DataResults.Rows.Item(Master_Loop)(1))
Trace.WriteLine("AD Current Path: " & newUser.Path)
'Update to try again
CycleSQLQUERY.CommandText = "UPDATE [dbo].[AMS_Processing_Table] SET [Process_FLAG] = 3 WHERE [TrackingID] = '" & Processing_DataResults.Rows.Item(Master_Loop)(0).ToString & "';"
WinEventLog.WriteEntry("Account Processing Thread: Null Var Found in Datatable. - " & Processing_DataResults.Rows.Item(Master_Loop)(1) & "-" & Master_Loop, EventLogEntryType.FailureAudit, 1614)
Continue For
End If
Trace.WriteLine("OLD: " & Replace(newUser.Path, newUser.Name & ",", ""))
Trace.WriteLine("New: " & LDAPSpecial & Replace(Processing_DataResults.Rows.Item(Master_Loop)(16), "/", "\/"))
If LCase(Replace(newUser.Path, newUser.Name & ",", "")) <> LCase(LDAPSpecial & Replace(Processing_DataResults.Rows.Item(Master_Loop)(16), "/", "\/")) Then
Thread.Sleep(100)
Dim UserObjPath As String = newUser.Path
Dim SuccessfulMove As Boolean = True
Try
newUser.MoveTo(New DirectoryEntry(LDAPSpecial & Replace(Processing_DataResults.Rows.Item(Master_Loop)(16), "/", "\/")))
Catch CatchALL As Exception
Trace.WriteLine(CatchALL.GetType)
Trace.WriteLine("OLD: " & Replace(newUser.Path, newUser.Name & ",", ""))
Trace.WriteLine("New: " & LDAPSpecial & Replace(Processing_DataResults.Rows.Item(Master_Loop)(16), "/", "\/"))
WinEventLog.WriteEntry("Account Processing Thread: Failed to move user object in AD. - " & Processing_DataResults.Rows.Item(Master_Loop)(1) & " - " & CatchALL.Message & "; OLD: " & LCase(Replace(newUser.Path, newUser.Name & ",", "")) & "; NEW:" & LCase(LDAPSpecial & Replace(Processing_DataResults.Rows.Item(Master_Loop)(16), "/", "\/")), EventLogEntryType.FailureAudit, 1611)
SuccessfulMove = False
CycleSQLQUERY.CommandText = "UPDATE [dbo].[AMS_Processing_Table] SET [Process_FLAG] = 3 WHERE [TrackingID] = '" & Processing_DataResults.Rows.Item(Master_Loop)(0).ToString & "';"
Try
CycleSQLQUERY.ExecuteNonQuery()
Catch ex_SQL As Exception
'addin 5/3/16
End Try
Continue For
End Try
If SuccessfulMove = True Then
Dim ChangeLineCount As Int64
任何不過,建議,提示,或修復將不勝感激。 這是一個多線程應用程序,特別是這個部分。我試圖撥出線程數量和相同的問題。
看來你不能大膽的代碼。我得到錯誤的位置在** newUser.MoveTo(New DirectoryEntry(LDAPSpecial&Replace(Processing_DataResults.Rows.Item(Master_Loop)(16),「/」,「\ /」)))** –
代碼塊是一個原因的代碼塊。 :) –
沒有人? : -/ 好吧,我想我很高興我不是唯一一個發現它很困難的人。 –