Results 1 to 18 of 18

Thread: .NET Framework issue

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2010
    Location
    Greece
    Posts
    58

    .NET Framework issue

    Hello to the community.
    I have an issue with NET Framework (I suppose). I use VS 2010 (VB.NET) and when I first created the application (New Project) I select the NET Framework 4.0
    I have made a simple form with a button, which when I press it, it pops up a new form with a textbox and an embedded text file. For the embedded text I used this method
    https://support.microsoft.com/en-us/kb/319291.
    In my PC (WIN 7 32-bit, NET framework 4.5), the form pops up fine. I used the application in two more PC (WIN XP 32-bit, NET FRAMEWORK 4 Extended + Client Profile) and i get the following error.
    Is it a NET Framework error, am I doing something wrong in coding or just something else?



    Code:
    See the end of this message for details on invoking 
    just-in-time (JIT) debugging instead of this dialog box.
    
    ************** Exception Text **************
    System.InvalidOperationException: An error occurred creating the form. See Exception.InnerException for details.  The error is: Could not load file or assembly 'Microsoft.VisualBasic.PowerPacks.Vs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualBasic.PowerPacks.Vs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
       at WindowsApplication1.Form2.InitializeComponent()
       at WindowsApplication1.Form2..ctor()
       --- End of inner exception stack trace ---
       at WindowsApplication1.My.MyProject.MyForms.Create__Instance__[T](T Instance)
       at WindowsApplication1.My.MyProject.MyForms.get_Form2()
       at WindowsApplication1.Form1.Button1_Click(Object sender, EventArgs e)
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    
    
    ************** Loaded Assemblies **************
    mscorlib
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1022 (RTMGDR.030319-1000)
        CodeBase: file:///c:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
    ----------------------------------------
    WindowsApplication1
        Assembly Version: 1.0.0.0
        Win32 Version: 1.0.0.0
        CodeBase: file:///C:/Documents%20and%20Settings/User/Desktop/TRN1.exe
    ----------------------------------------
    Microsoft.VisualBasic
        Assembly Version: 10.0.0.0
        Win32 Version: 10.0.30319.1 built by: RTMRel
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualBasic/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
    ----------------------------------------
    System
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1001 built by: RTMGDR
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
    ----------------------------------------
    System.Core
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 built by: RTMRel
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
    ----------------------------------------
    System.Windows.Forms
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1002 built by: RTMGDR
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    ----------------------------------------
    System.Drawing
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1001 built by: RTMGDR
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    ----------------------------------------
    System.Runtime.Remoting
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Remoting/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
    ----------------------------------------
    
    ************** JIT Debugging **************
    To enable just-in-time (JIT) debugging, the .config file for this
    application or computer (machine.config) must have the
    jitDebugging value set in the system.windows.forms section.
    The application must also be compiled with debugging
    enabled.
    
    For example:
    
    <configuration>
        <system.windows.forms jitDebugging="true" />
    </configuration>
    
    When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the computer
    rather than be handled by this dialog box.

  2. #2
    Frenzied Member IanRyder's Avatar
    Join Date
    Jan 2013
    Location
    Healing, UK
    Posts
    1,232

    Re: .NET Framework issue

    Hi,

    Have a look at the first answer here to see if this helps:-

    Missing Microsoft.VisualBasic.PowerPacks

    Cheers,

    Ian

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2010
    Location
    Greece
    Posts
    58

    Re: .NET Framework issue

    OK. I found that it has somethinf to do with Microsoft Visual PowerPacks. I installed version 10, so now form with embedded text pops up.
    Still I get this error when I close the form.
    In the ERROR PROMPT, when i press the "X" icon, the error just close. When I press QUIT, the application just shut down.


    Code:
    See the end of this message for details on invoking 
    just-in-time (JIT) debugging instead of this dialog box.
    
    ************** Exception Text **************
    System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
       at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
       at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
       at System.Collections.Generic.List`1.Enumerator.MoveNext()
       at Microsoft.VisualBasic.PowerPacks.ShapeCollection.Dispose(Boolean disposing)
       at Microsoft.VisualBasic.PowerPacks.ShapeContainer.Dispose(Boolean disposing)
       at System.ComponentModel.Component.Dispose()
       at System.Windows.Forms.Control.Dispose(Boolean disposing)
       at System.Windows.Forms.Form.Dispose(Boolean disposing)
       at WindowsApplication1.Form2.Dispose(Boolean disposing)
       at System.Windows.Forms.Form.WmClose(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    
    
    ************** Loaded Assemblies **************
    mscorlib
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1022 (RTMGDR.030319-1000)
        CodeBase: file:///c:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
    ----------------------------------------
    WindowsApplication1
        Assembly Version: 1.0.0.0
        Win32 Version: 1.0.0.0
        CodeBase: file:///C:/Documents%20and%20Settings/User/Desktop/TRN1.exe
    ----------------------------------------
    Microsoft.VisualBasic
        Assembly Version: 10.0.0.0
        Win32 Version: 10.0.30319.1 built by: RTMRel
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualBasic/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
    ----------------------------------------
    System
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1001 built by: RTMGDR
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
    ----------------------------------------
    System.Core
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 built by: RTMRel
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
    ----------------------------------------
    System.Windows.Forms
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1002 built by: RTMGDR
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    ----------------------------------------
    System.Drawing
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1001 built by: RTMGDR
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    ----------------------------------------
    System.Runtime.Remoting
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Remoting/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
    ----------------------------------------
    Microsoft.VisualBasic.PowerPacks.Vs
        Assembly Version: 10.0.0.0
        Win32 Version: 10.0.20911.1
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic.PowerPacks.Vs/10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.PowerPacks.Vs.dll
    ----------------------------------------
    System.Xml
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1015 built by: RTMGDR
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
    ----------------------------------------
    
    ************** JIT Debugging **************
    To enable just-in-time (JIT) debugging, the .config file for this
    application or computer (machine.config) must have the
    jitDebugging value set in the system.windows.forms section.
    The application must also be compiled with debugging
    enabled.
    
    For example:
    
    <configuration>
        <system.windows.forms jitDebugging="true" />
    </configuration>
    
    When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the computer
    rather than be handled by this dialog box.

  4. #4
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: .NET Framework issue

    I assume it has to do with what your code is doing.

    System.InvalidOperationException: Collection was modified; enumeration operation may not execute.

    usually means that you are accessing a collection, in this case I'm assuming some shapes in your code, while other code is making changes to the collection at the same time.

    Apparently, since you are closing the form, the form is trying to clean up and get rid of said shapes, but you have code that is looping through the shapes.
    If you are going to close the form, you will have to stop accessing things on the form from your code.
    Usually, I would have a flag, such as

    Private Leaving as Boolean

    And where I do my loop, or in my timer perhaps, I would check the flag
    If Not Leaving Then
    or
    Do Until Leaving
    or
    Do While Not Leaving
    etc...

    If the form is selected to be closed, then in the Form_Closing event, I would check the flag, and if it was not set True, then Set it to True, and cancel the closing (for now).
    When the looping or timer driven code sees that we are leaving, it will fall out of the loop (or disable the timer) and then call the Close method of the form.
    This time, the Closing event handler will see the flag is set, and not cancel the closing of the form, and the form will exit cleanly without your code still trying to access things on the form.

    But, since we don't really see your code, its a guess.

  5. #5
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: .NET Framework issue

    More often than not, it happens when someone does something like this:

    Code:
    For Each t as SomeItem In SomeItemList
      t.Remove 'or does something that actually changes the contents of the list/collection itself
    NExt
    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: .NET Framework issue

    I agree. That exception is generally a result of you iterating through a collection and modifying it. So, the place to look is generally at any For loop you might have in the code which runs when the form closes. Of course, that loop doesn't necessarily have to be in the form that is closing, but could be in a different form. When the exception happens, you should be taken to the line where the exception occured as long as you are running in the debugger.
    My usual boring signature: Nothing

  7. #7
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: .NET Framework issue

    Here's the part that bugs me about those answers: that is certainly what causes a "Collection was modified" exception. But look at the call stack. Everything is non-user code: WndProc() gets its close message, calls OnWmClose(), calls Form2.Dispose(). That's our first chance at user code here, but the call stack proceeds to Form.Dispose() so it's not user code. From there we end up in the PowerPacks and see that something internal to ShapeCollection.Dispose() is causing the problem. But when I peek at that, I don't see a foreach loop or any other kind of enumeration that'd throw this exception. It calls the Count property and the Clear() method, but these are native to List<T> rather than the LINQ implementations that might enumerate.

    So I'm perplexed. Unless OP is modifying that collection off in some thread, everything in this call stack is non-user code and points to "a bug with ShapeCollection".

    stratos, we're going to have to see more of your code to figure this out. It might not actually be your fault, it could be something stupid MS is doing. But there is this solemn warning in the documentation:
    Be careful that you do not create more than one ShapeContainer for each form or container; doing this may introduce unexpected behavior.
    ShapeContainer is a very "weird" control in Windows Forms.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  8. #8
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: .NET Framework issue

    Yeah, it did occur to me that the way the ShapeContainer is implemented, it is a VERY strange animal in the .NET world. They aren't really controls and they aren't really not controls. However, I have not encountered the problem on the one use of the Shape Container I have, and the situation is one where I create a collection of lines, which seems like it would result in a similar problem if it was the PowerPack itself that was buggy. It may be a combination. On the other hand, I was kind of expecting the OP to come back with: I don't have any code in the Closing event, so it can't be me, which would make things more interesting.
    My usual boring signature: Nothing

  9. #9

    Thread Starter
    Member
    Join Date
    Sep 2010
    Location
    Greece
    Posts
    58

    Re: .NET Framework issue

    Here is the code from Form2.Designer.vb

    Code:
    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
    Partial Class Form2
        Inherits System.Windows.Forms.Form
    
        'Form overrides dispose to clean up the component list.
        <System.Diagnostics.DebuggerNonUserCode()> _
        Protected Overrides Sub Dispose(ByVal disposing As Boolean)
            Try
                If disposing AndAlso components IsNot Nothing Then
                    components.Dispose()
                End If
    
            Finally
                MyBase.Dispose(disposing)
            End Try
        End Sub
    
        'Required by the Windows Form Designer
        Private components As System.ComponentModel.IContainer
    
        'NOTE: The following procedure is required by the Windows Form Designer
        'It can be modified using the Windows Form Designer.  
        'Do not modify it using the code editor.
        <System.Diagnostics.DebuggerStepThrough()> _
        Private Sub InitializeComponent()
            Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form2))
            Me.TextBox1 = New System.Windows.Forms.TextBox()
            Me.Label1 = New System.Windows.Forms.Label()
            Me.Label2 = New System.Windows.Forms.Label()
            Me.ShapeContainer1 = New Microsoft.VisualBasic.PowerPacks.ShapeContainer()
            Me.LineShape1 = New Microsoft.VisualBasic.PowerPacks.LineShape()
            Me.SuspendLayout()
            '
            'TextBox1
            '
            Me.TextBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(161, Byte))
            Me.TextBox1.Location = New System.Drawing.Point(0, 1)
            Me.TextBox1.Multiline = True
            Me.TextBox1.Name = "TextBox1"
            Me.TextBox1.ReadOnly = True
            Me.TextBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
            Me.TextBox1.Size = New System.Drawing.Size(805, 446)
            Me.TextBox1.TabIndex = 0
            '
            'Label1
            '
            Me.Label1.AutoSize = True
            Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(161, Byte))
            Me.Label1.Location = New System.Drawing.Point(-1, 468)
            Me.Label1.Name = "Label1"
            Me.Label1.Size = New System.Drawing.Size(291, 13)
            Me.Label1.TabIndex = 1
            Me.Label1.Text = "->Use Page Up/ Down or Mouse Wheel to scroll<-"
            '
            'Label2
            '
            Me.Label2.AutoSize = True
            Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(161, Byte))
            Me.Label2.Location = New System.Drawing.Point(670, 468)
            Me.Label2.Name = "Label2"
            Me.Label2.Size = New System.Drawing.Size(107, 13)
            Me.Label2.TabIndex = 2
            Me.Label2.Text = "Press END to exit"
            '
            'ShapeContainer1
            '
            Me.ShapeContainer1.Location = New System.Drawing.Point(0, 0)
            Me.ShapeContainer1.Margin = New System.Windows.Forms.Padding(0)
            Me.ShapeContainer1.Name = "ShapeContainer1"
            Me.ShapeContainer1.Shapes.AddRange(New Microsoft.VisualBasic.PowerPacks.Shape() {Me.LineShape1})
            Me.ShapeContainer1.Size = New System.Drawing.Size(777, 515)
            Me.ShapeContainer1.TabIndex = 3
            Me.ShapeContainer1.TabStop = False
            '
            'LineShape1
            '
            Me.LineShape1.Name = "LineShape1"
            Me.LineShape1.X1 = 3
            Me.LineShape1.X2 = 777
            Me.LineShape1.Y1 = 450
            Me.LineShape1.Y2 = 450
            '
            'Form2
            '
            Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.ClientSize = New System.Drawing.Size(777, 515)
            Me.Controls.Add(Me.Label2)
            Me.Controls.Add(Me.Label1)
            Me.Controls.Add(Me.TextBox1)
            Me.Controls.Add(Me.ShapeContainer1)
            Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
            Me.MaximizeBox = False
            Me.Name = "Form2"
            Me.Text = "INFO"
            Me.ResumeLayout(False)
            Me.PerformLayout()
    
        End Sub
        Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
        Friend WithEvents Label1 As System.Windows.Forms.Label
        Friend WithEvents Label2 As System.Windows.Forms.Label
        Friend WithEvents ShapeContainer1 As Microsoft.VisualBasic.PowerPacks.ShapeContainer
        Friend WithEvents LineShape1 As Microsoft.VisualBasic.PowerPacks.LineShape
    End Class


    Here is Form2.vb
    Elements: Textbox(x1), Labels(x2), LineShape(x1)
    Do you think it might be the Lineshape the problem? :/

    Code:
    Imports System.IO
    Imports System.Reflection
    Imports System.Text
    Public Class Form2
        Inherits System.Windows.Forms.Form
    
        Dim _textStreamReader As StreamReader
        Dim _assembly As [Assembly]
    
    
    Private WithEvents KeyLogger As New Timer With {.Interval = 1, .Enabled = True}
    
    
    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
    
            Try
                _assembly = [Assembly].GetExecutingAssembly()
                _textStreamReader = New StreamReader(_assembly.GetManifestResourceStream("WindowsApplication1.Trainer_VB.txt"))
            Catch ex As Exception
                MessageBox.Show("Resource wasn't found!", "Error")
            End Try
    
    
    
            Try
                If _textStreamReader.Peek() <> -1 Then
                    TextBox1.Text = _textStreamReader.ReadToEnd()
                End If
            Catch ex As Exception
                MessageBox.Show("Error reading stream!")
            End Try
        End Sub
    
    
        Private Sub KeyLogger_Tick() Handles KeyLogger.Tick
            TextBox1.Select(0, 0)
            If GetAsyncKeyState(Keys.End) Then
                Me.Close()
            End If
        End Sub
    
    End Class

  10. #10
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: .NET Framework issue

    I'm really stumped, I want to say it's a bug in the power packs but I can't reproduce it. There's some things going on in your code that I don't like, but I just spent the last half-hour trying to bend them such that they'd break things in the way I expect and they just don't. I'll discuss what I suspected and tried so anyone else trying to help doesn't waste their time.

    • My first thought was that maybe this wasn't one of the WinForms timer, but the event name suggests we're working with good old System.Windows.Forms.Timer, which is one of the two appropriate ones. Myth busted.
    • Next, I noticed that normally the designer uses the constructor for S.W.F.Timer that takes a parameter, and wondered if not doing so would make the Timer use a free-threaded context. Myth busted, InvokeRequired() returned false in the event handler.
    • I nearly gave up, but then I saw the 1ms timer interval combined with GetAsyncKeyState() and a Me.Close() call. Could it be possible that Me.Close() gets called twice, somehow violating the expectations of ShapeContainer? No, I set up a test that duplicates the scenario and Me.Close() also shuts down the timer, and if any extra ticks are queued it ignores them. Hmph.


    Now, there's one important difference. I'm doing this in VS 2015 Community Edition, and we could have different versions of the VB PowerPack. Maybe in an older version, their Dispose() logic did something stupid and could toss out an error. That'd be tough for me to reproduce. Then, a brilliant idea struck me.

    "Why don't I ask the internet if this problem's been seen before?" It turns out it has, and people found a wonky solution. Relevant discussion:

    The issue appears to be that shape controls remove themselves from ShapeContainer.Shapes collection when .Dispose is called on them. A logical implementation of ShapeContainer.Dispose would include iterating through the shapes collection and calling .Dispose on each one of them... which in term causes the exception as mentioned.
    This is weird as heck to me. I'm looking at disassembled code, and while the shapes DO remove themselves, the ShapeContainer isn't using an enumerator. But then it hit me: what if I have a newer version of Microsoft.VisualBasic.PowerPacks.Vs.dll? The post is from 2010, and my version's from 2012. Your program reports a version number of 10.0.20911.1, mine reports 11.0.50727.1. Hmm. They could've changed the code since then.

    I'm bored and waiting on someone to give me SSH access to a server, so I went looking for an old version. It's actually hard. The first site tried to download a virus. Thanks, internet. So, if you want to help me once and for all, we'd have to figure out some way for you to send me your copy of the DLL. I'm pretty sure this forum doesn't like you attaching or linking to binaries, so maybe we should discuss that via DM and go do it in some shady place where the forum won't be liable.

    Regardless, VS 2010 is pretty old, and obviously they've made some improvements. VS 2015 is slow as heck but free, so you might try installing that. Or, you can try the code in the post I linked.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  11. #11

    Thread Starter
    Member
    Join Date
    Sep 2010
    Location
    Greece
    Posts
    58

    Re: .NET Framework issue

    @ Sitten Spynne
    Sent you PM.
    P.S. I will remove the line shape and I will try again to check if I get this error.
    Besides , lineshape it's not so important for the form, so if that's the "little devil", I will delete it.
    Last edited by stratos; Sep 25th, 2015 at 12:09 AM.

  12. #12

    Thread Starter
    Member
    Join Date
    Sep 2010
    Location
    Greece
    Posts
    58

    Re: .NET Framework issue

    Guys thanks for the help. I removed the line and I don't get this error any more. But still, if you want to help me to fix the error in some other case I may need, it is appreciated.

  13. #13
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: .NET Framework issue

    Huh. Even disassembling your version of the PowerPack, I can't find an enumeration in the spot it claims. Maybe there's some kind of JIT tomfoolery going on.

    If you need something like LineShape, we can totally help with that. Obviously there's some kind of glitch in it.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  14. #14
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: .NET Framework issue

    I've never used the Shape Controls. Even in VB6.
    They weren't part of VB.Net originally, but were only added to .Net because of complaints from the users who were used to using them from VB6.
    If you need to have a line or other shape on a form, I would just add code to the paint event to draw the line or shape.
    Perhaps it may not be as convenient as dropping and sizing a shape in the IDE, but I guess I got started long before the Visual xxxx languages, and so am quite used to drawing things for display.

  15. #15
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: .NET Framework issue

    It gets a little tricky if you need that line to overlap several other controls. I'm not even sure if the power pack handles that right, but it's a case where "just draw the line yourself" isn't easily applied.

    ...unless you're using WPF.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  16. #16
    Frenzied Member
    Join Date
    Jul 2011
    Location
    UK
    Posts
    1,335

    Re: .NET Framework issue

    Looks to have been fixed in versions after 10.0.20911.1

    See the discussion at http://stackoverflow.com/questions/1...-execute-on-fo


    ShapeCollection.Dispose for v10.0.20911.1:
    VB.NET Code:
    1. ' Microsoft.VisualBasic.PowerPacks.ShapeCollection
    2. <EditorBrowsable(EditorBrowsableState.Always)>
    3. Private Sub Dispose(disposing As Boolean)
    4.     If Not Me.m_Disposed AndAlso disposing Then
    5.         Try
    6.             Dim enumerator As List(Of Shape).Enumerator = Me.m_Shapes.GetEnumerator()
    7.             While enumerator.MoveNext()
    8.                 Dim current As Shape = enumerator.Current
    9.                 current.Dispose()
    10.             End While
    11.         Finally
    12.             Dim enumerator As List(Of Shape).Enumerator
    13.             (CType(enumerator, IDisposable)).Dispose()
    14.         End Try
    15.         Me.m_Shapes.Clear()
    16.         Me.m_Shapes = Nothing
    17.     End If
    18.     Me.m_Disposed = True
    19. End Sub

    ShapeCollection.Dispose for v10.0.40219.1:
    VB.NET Code:
    1. ' Microsoft.VisualBasic.PowerPacks.ShapeCollection
    2. <EditorBrowsable(EditorBrowsableState.Always)>
    3. Private Sub Dispose(disposing As Boolean)
    4.     ' The following expression was wrapped in a checked-statement
    5.     If Not Me.m_Disposed AndAlso disposing Then
    6.         For i As Integer = Me.m_Shapes.Count - 1 To 0 Step -1
    7.             Dim shape As Shape = Me.m_Shapes(i)
    8.             shape.Dispose()
    9.         Next
    10.         Me.m_Shapes.Clear()
    11.         Me.m_Shapes = Nothing
    12.     End If
    13.     Me.m_Disposed = True
    14. End Sub

  17. #17
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: .NET Framework issue

    Quote Originally Posted by passel View Post
    I've never used the Shape Controls. Even in VB6.
    They weren't part of VB.Net originally, but were only added to .Net because of complaints from the users who were used to using them from VB6.
    If you need to have a line or other shape on a form, I would just add code to the paint event to draw the line or shape.
    Perhaps it may not be as convenient as dropping and sizing a shape in the IDE, but I guess I got started long before the Visual xxxx languages, and so am quite used to drawing things for display.
    I want my lines to have events.

    That was the reason I used the PowerPacks for something. When the user moused over a line I wanted it to turn red (not easy with drawing), when they moused over some other controls other lines would change color (easy with drawing), and the line had to be clickable (also not easy with drawing on the form). So, there are some things where Powerpack shapes are just easier, but they aren't real controls, so they don't act the same way.
    My usual boring signature: Nothing

  18. #18

    Thread Starter
    Member
    Join Date
    Sep 2010
    Location
    Greece
    Posts
    58

    Re: .NET Framework issue

    Thanks again guys! I will try some of the above things you have mentioned and check what's going on. I will start with drawing a Line using only VB code (no "drag and drop" at all)

Tags for this Thread

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