Results 1 to 9 of 9

Thread: [RESOLVED] "Out of Memory" what happened!

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2000
    Location
    Manchester NH
    Posts
    833

    Resolved [RESOLVED] "Out of Memory" what happened!

    i am working on a user control. embedded in my user control is another user control. all of a suddon while programming some simple stuff i get an "out of memory error message"

    i can no longer load my project (after reboots etc)

    i start a new project, copy the control.vb files into a new project folder.. add then add the control to the new project

    i can view the design and the code of the control.

    when i attempt to drag the control onto another control in the same project i get an error message

    "failed to create component... 'system.outofmemoryexception. out of memory"
    Kurt Simons
    [I know I'm a hack but my clients don't!]

  2. #2

    Re: "Out of Memory" what happened!

    All I can think of is that you're doing something in GDI+ that causes the error. Post the code of the User control.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2000
    Location
    Manchester NH
    Posts
    833

    Re: "Out of Memory" what happened!

    i confirmed to code in this block of text is causing the issue

    all code from user control



    Code:
        Dim Dragging As Boolean
        Dim HiddenFolders As String
    
    
        Public Sub GotFoldersAndTemplates(ByVal InD As String)
    
            On Error GoTo 1000
    
            TreeView.Nodes.Clear()
    
            Dim a As Integer
            Dim b As Integer
            Dim ST() As String
    
    
            Dim D As String
    
    
    
    
            D = GetXMLElement("FOLDERS", InD)
    
            ST = Split(D, "<FOLDER>")
    
            Dim GotOne As Boolean
            Dim LeftOneBehind As Boolean
    
    10:
    
            GotOne = False
            LeftOneBehind = False
    
            Dim ID As String
            Dim Fname As String
            Dim Active As String
            Dim Parent As String
            Dim tType As String
            Dim tExpander As String
    
    
            HiddenFolders = Chr(1)
            Dim NODDE() As TreeNode
    
            For a = 1 To UBound(ST)
    
                If ST(a) <> "" Then
    
                    ID = GetXMLElement("ID", ST(a))
                    Fname = unXMLit(GetXMLElement("NAME", ST(a)))
                    Active = GetXMLElement("ACTIVE", ST(a))
                    Parent = GetXMLElement("PARENT", ST(a))
    
    
                    If Active = "F" Then
    
                        HiddenFolders = HiddenFolders & ID & Chr(1)
                    End If
    
    
                    If Parent = "0" Then
                        TreeView.Nodes.Add("FOLDER" & Active & ID, Fname)
                        ST(a) = ""
                        GotOne = True
                    Else
    
    
                        NODDE = TreeView.Nodes.Find("FOLDER" & Parent, True)
    
                        If UBound(NODDE) = 0 Then
    
                            NODDE(0).Nodes.Add("FOLDER" & ID, Fname)
                            ST(a) = ""
                            GotOne = True
    
                        Else
    
                            TreeView.Nodes.Add("FOLDER" & ID, Fname)
                            ST(a) = ""
                            GotOne = True
    
                        End If
    
    
                    End If
    
    
                End If
    
    
            Next
    
            If LeftOneBehind = True Then
    
                If GotOne = False Then
                    Beep()
                End If
    
            End If
    
    
    
            D = GetXMLElement("TEMPLATES", InD)
    
            ST = Split(D, "<TEMPLATE>")
    
    
            For a = 1 To UBound(ST)
    
                If ST(a) <> "" Then
    
                    ID = GetXMLElement("ID", ST(a))
                    Fname = unXMLit(GetXMLElement("NAME", ST(a)))
                    ' Active = GetXMLElement("ACTIVE", ST(a))
                    Parent = GetXMLElement("FOLDER", ST(a))
                    tType = GetXMLElement("TYPE", ST(a))
                    tExpander = GetXMLElement("EXPANDER", ST(a))
    
    
    
    
                    If tType <> "SCRIPT" Then
    
                        NODDE = TreeView.Nodes.Find("FOLDER" & Parent, True)
    
                        If UBound(NODDE) = 0 Then
    
    
    
                            If tExpander = "Y" Then
    
                                NODDE(0).Nodes.Add("FOLDEREXPANDER" & ID, Fname)
    
                                NODDE = TreeView.Nodes.Find("FOLDEREXPANDER" & ID, True)
                                Dim C As Integer
    
                                For C = 1 To 50
                                    NODDE(0).Nodes.Add("TEMPLATEEXPANDER" & ID & "-" & C, "Expander - " & C)
                                Next
    
                            Else
    
    
                                NODDE(0).Nodes.Add("TEMPLATE" & ID, Fname)
    
                            End If
    
    
    
                        End If
    
                    End If
    
                End If
    
            Next
    
    
    
    
    
    
    
    
            Exit Sub
    1000:
            MsgBox(Err.Description)
    
    
        End Sub
    
    
        Private Sub ctlTemplates_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
    
            ImageList1.Images.Add("FOLDER", Image.FromFile("c:\HATMOS-CG\Icons\FOLDER.ico"))
            ImageList1.Images.Add("CG", Image.FromFile("c:\HATMOS-CG\Icons\FSCG.ico"))
            ImageList1.Images.Add("NO", Image.FromFile("c:\HATMOS-CG\Icons\NO.ico"))
    
    
    
        End Sub
    
        Private Sub TreeView_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView.AfterSelect
    
        End Sub
    
    
    
        Private Sub TreeView_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TreeView.MouseDown
    
    
            Dim selectedTreeview As TreeView = CType(sender, TreeView)
    
    
            If e.Button = Windows.Forms.MouseButtons.Right Or 1 = 1 Then
    
    
                'As the mouse moves over nodes, provide feedback to 
                'the user by highlighting the node that is the 
                'current drop target
    
                '  Dim pt As Point = _
                ' CType(sender, TreeView).PointToClient(New Point(e.X, e.Y))
    
    
    
                '   Dim pt As Point = selectedTreeview.PointToClient(New Point(e.X, e.Y))
    
                Dim targetNode As TreeNode = selectedTreeview.GetNodeAt(e.X, e.Y)
    
                selectedTreeview.SelectedNode = targetNode
    
            End If
    
    
    
            If selectedTreeview.SelectedNode Is Nothing Then Exit Sub
    
    
    
            If e.Button = Windows.Forms.MouseButtons.Right Then
    
                '            Me.MENU1.Show(selectedTreeview, New Point(e.X, e.Y))
    
            End If
    
    
        End Sub
    
        Private Sub TreeView_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TreeView.MouseMove
            On Error GoTo 1000
    
            If e.Button <> Windows.Forms.MouseButtons.Left Then
                Dragging = False
                Exit Sub
            End If
    
            If Dragging = True Then Exit Sub
    
            If TreeView.SelectedNode.Name.StartsWith("FOLDER") Then Exit Sub
    
            TreeView.DoDragDrop(vbCrLf & "[<mos><itemID>2</itemID><mosID>HATMOS.CG</mosID><mosAbstract>" & TreeView.SelectedNode.Text & "</mosAbstract><objID>CG</objID><objDur>1</objDur><objTB></objTB><abstract>NewsChannel Branding \Branding Off</abstract><itemEdStart></itemEdStart><mosExternalMetadata><mosScope>STORY</mosScope><CGDATA>NewsChannel Branding\Branding Off</CGDATA><modBY><mod><usr>AWORMSER</usr><time>2003-07-15T11:29:37</time><cpu>WESH-917000060</cpu></mod></modBY></mosExternalMetadata><itemSlug>MOS Commands-2</itemSlug></mos>]" & vbCrLf, DragDropEffects.Copy)
    
    
            Exit Sub
    1000:
    
    
    
    
        End Sub
    
    
        Private Sub TreeView_AfterSelect_1(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView.AfterSelect
    
        End Sub
    
    
        Private Sub TreeView_DrawNode(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawTreeNodeEventArgs) Handles TreeView.DrawNode
    
            If e.Node.Index < 0 Then Exit Sub
            If e.Bounds.X < 5 Then Exit Sub
    
    
            Dim Ftemplate As New Font("Arial", 10, FontStyle.Regular)
            Dim FtemplateH As New Font("Arial", 11, FontStyle.Bold)
            Dim Ffolder As New Font("Arial", 12, FontStyle.Bold)
    
            Dim Phighlight As New Pen(Color.Blue, 2)
    
    
    
            e.Graphics.FillRectangle(Brushes.White, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Width)
    
    
            If e.Node.Name.StartsWith("FOLDER") Then
    
                e.Graphics.DrawImage(ImageList1.Images.Item(0), e.Bounds.X + 5, e.Bounds.Y + 3)
                e.Graphics.DrawString(e.Node.Text, Ffolder, Brushes.Black, e.Bounds.X + 25, e.Bounds.Y + 3)
    
    
                If e.Node.IsSelected Then
    
                    e.Graphics.DrawRectangle(Phighlight, e.Bounds.X, e.Bounds.Y + 3, e.Graphics.MeasureString(e.Node.Text, Ffolder).Width + 25 + 2, e.Bounds.Height - 4)
    
                End If
    
    
            Else
    
    
    
    
    
                If e.Node.IsSelected Then
                    e.Graphics.FillRectangle(Brushes.Blue, e.Bounds.X + 24, e.Bounds.Y + 3, e.Graphics.MeasureString(e.Node.Text, FtemplateH).Width, e.Bounds.Height - 5)
                    e.Graphics.DrawString(e.Node.Text, FtemplateH, Brushes.White, e.Bounds.X + 25, e.Bounds.Y + 3)
    
                Else
                    e.Graphics.DrawString(e.Node.Text, Ftemplate, Brushes.Black, e.Bounds.X + 25, e.Bounds.Y + 3)
                End If
    
    
                e.Graphics.DrawImage(ImageList1.Images.Item(1), e.Bounds.X + 5, e.Bounds.Y + 4)
    
    
            End If
    
    
    
    
    
    
    
        End Sub
    Kurt Simons
    [I know I'm a hack but my clients don't!]

  4. #4

    Re: "Out of Memory" what happened!

    The mixed use of VB6 style Error Handling has me cringe a little...but I don't see anything right off hand that would throw an Out Of Memory exception. Perhaps it has to do with the Graphics? But I doubt it...someone that has more experience with that error message can help you out.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2000
    Location
    Manchester NH
    Posts
    833

    Re: "Out of Memory" what happened!

    nevermind... i figured it out. an icon was invalid. why it causes that error is nutz
    Kurt Simons
    [I know I'm a hack but my clients don't!]

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2000
    Location
    Manchester NH
    Posts
    833

    Re: [RESOLVED] "Out of Memory" what happened!

    how do i delete this thread?
    Kurt Simons
    [I know I'm a hack but my clients don't!]

  7. #7

    Re: [RESOLVED] "Out of Memory" what happened!

    You don't.

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2000
    Location
    Manchester NH
    Posts
    833

    Re: [RESOLVED] "Out of Memory" what happened!

    thanks.

    so here is what i did to make me think .net screwed up my entire project.

    i didn't error trap

    Private Sub ctlTemplates_Load

    in the load procedure i loaded images from disk, vb was unable to load one of the images... this caused a "out of memory error" which was untrapped. because this user control sat on the main user control for the project it executed when the project opened.

    cost me about two hours of time and alot of frustration and its all on me
    Kurt Simons
    [I know I'm a hack but my clients don't!]

  9. #9

    Re: [RESOLVED] "Out of Memory" what happened!

    Glad you figured it out. Now you know for the future!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width