XML 문서에서 항목 가져 오기를 추가하고 목록보기로로드하려고합니다. 프로젝트 projects.Add (project)에 System.OutOfMemory 예외가 계속 발생합니다. 내가 뭘 잘못하고 어떻게 제대로합니까? 나는이 코드를 murach의 시작 visual basic.NET에서 얻었다. 당신은 루프 내에서 독자를 진행하거나이 루프를 제거하거나이xml에서 항목 가져 오기 및 목록보기에 추가
Do While ProjectReader.Name = "projecttype"
project.name = ProjectReader.Item("name")
'TODO: extension
'TODO: imagepath
projects.Add(project)
Loop
:이 프로그램을 실행할 때 그것은 당신이 여기에 무한 루프가있는 목록보기
Structure ProjectInfo
Dim name As String
Dim fileextentions As ArrayList
Dim imagepath As String
End Structure
Dim project As ProjectInfo
Dim projects As New ArrayList()
'The project is loading
Private Sub diaNewProject_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Set the default filepath
txtFilepath.Text = "C:\Users\" & GetUserName() & "\Documents\Homerun IDE\Projects"
'Load the project types
If LoadProjects() Then
For Each Me.project In projects
'Add the items
ltvItems.Items.Add(project.name)
Next
Else
'Close the form
Me.Close()
End If
End Sub
Private Function LoadProjects() As Boolean
Dim ProjectReader As New XmlTextReader(_globals.ProjectsListFilename)
ProjectReader.WhitespaceHandling = WhitespaceHandling.None
Try
Do Until ProjectReader.Name = "projecttype"
ProjectReader.Read()
Loop
Do While ProjectReader.Read()
If ProjectReader.Name = "projecttype" Then
project.name = ProjectReader.Item(Name)
projects.Add(project)
End If
Loop
ProjectReader.Close()
Catch ex As XmlException
_logger.LogException(ex, TraceEventType.Critical, "Load Projects Error", "Make sure that your projectstypes.xml file is correctly formatted. In your settings " & _
"you can reset the file to your its default.")
Return False
End Try
Return True
End Function
XML 파일에있는 항목의 수를 알 수 없기 때문에 루프를 진행할 방법이 보이지 않으며 루프없이 어떻게 처리 할 수 있습니까? – muckdog12
XML 파일의 세부 사항을 모르지만이 루프 맨 아래에'ProjectReader.Read()'를 추가하고 싶을 것입니다. – EndangeredMassa