【发布时间】:2016-07-03 05:05:49
【问题描述】:
我收到一个错误:
System.DirectoryServices.dll 中出现“System.AccessViolationException”类型的未处理异常
随机移动少数用户。
这很奇怪,它们发生的时间似乎没有押韵或原因,我有它在尝试中,但由于某种原因,最近它开始使应用程序崩溃。在调试器中,它们会弹出,您可以继续处理它们并完成线程,“失败”操作起作用,并在下一个周期重新运行移动。
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), "/", "\/")))
-
一个代码块是一个代码块是有原因的。 :)
-
没有人吗? :-/ 好吧,我想我很高兴我不是唯一一个觉得困难的人。
标签: .net vb.net visual-studio-2013 active-directory