我得到一个错误:型“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),“/”,“\ /”)))** –
代码块是一个原因的代码块。 :) –
没有人? : -/ 好吧,我想我很高兴我不是唯一一个发现它很困难的人。 –