dcsimg
Results 1 to 8 of 8
  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2003
    Posts
    99

    Resolved [RESOLVED] How to investigate "System.InvalidOperationException"?

    Hello

    A GUI application I wrote with VB.Net 2008 Express works fine on the XPSP3 host I use to develop, but fails starting on a fresh Windows 7 host with the following error:

    Description: Stopped working
    Problem signature:
    Problem Event Name: CLR20r3
    Problem Signature 01: myapp.exe
    Problem Signature 02: 1.0.0.0
    Problem Signature 03: 4eb2a385
    Problem Signature 04: myapp
    Problem Signature 05: 1.0.0.0
    Problem Signature 06: 4eb2a385
    Problem Signature 07: f
    Problem Signature 08: c6
    Problem Signature 09: System.InvalidOperationException
    OS Version: 6.1.7600.2.0.0.256.1
    Locale ID: 1033
    The Windows 7 has .Net framework 4 by default, so figured maybe the framework isn't downward-compatible, but when I run the .Net 2.0 framework installer (dotnetfx.exe), it says it's already installed. Weird :-/

    I also tried running the app as Admin, with no change.

    Next, I found this thread here, that says to "Try handling the UnhandledException event of your application, which all VB.NET WinForms apps should do. Hopefully it should be able to tell you exactly what's happened.".

    So following this article, I added a "Private Sub OnThreadException()" and a "Public Sub New" to Form1 thusly:
    Code:
    Public Class Form1
        Inherits System.Windows.Forms.Form
    
        Public Sub New()
            AddHandler Application.ThreadException, AddressOf OnThreadException
            InitializeComponent()
        End Sub
    
        Private Sub OnThreadException(ByVal sender As Object, _
                           ByVal e As ThreadExceptionEventArgs)
            ' This is where you handle the exception
            MessageBox.Show(e.Exception.Message)
        End Sub
    Next, after a successful build, I downloaded the app on the Windows 7, and re-ran this new version... but get the exact same error with no extra help.

    Any idea what I could try to understand why the application doesn't start at all?

    Thank you.

  2. #2

    Re: How to investigate "System.InvalidOperationException"?

    Do you get any other information in the Exception? Such as, a routine or a stack trace that shows where the Exception originated from?

    If the error happens when your application first runs, you should post the Load() routine of the application here so we can see where an Exception might possibly derive from.

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    32,188

    Re: How to investigate "System.InvalidOperationException"?

    The exception might derive from earlier than Load. It actually sounds like it might be coming from the initialization of a global or Shared object, which initialization is executed prior to the contructor of the startup form.
    My usual boring signature: Nothing

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Sep 2003
    Posts
    99

    Re: How to investigate "System.InvalidOperationException"?

    Thanks for your help. Indeed, more googling showed that it's possible to have the application handle earlier, deeper issues by adding another exception handler:
    Code:
    Public Sub New()
        AddHandler Application.ThreadException, AddressOf OnThreadException
    
        'Added this
        AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf UnhandledExceptionEventRaised
    
        InitializeComponent()
    End Sub
    
    'Added this
    Sub UnhandledExceptionEventRaised(ByVal sender As Object, ByVal e As UnhandledExceptionEventArgs)
        If e.IsTerminating Then
            Dim o As Object = e.ExceptionObject
            MessageBox.Show(o.ToString) ' use EventLog instead
        End If
    End Sub
    It showed that I was missing a component that is not part of the .Net framework:
    System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualBasic.PowerPacks.Vs, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
    File name: 'Microsoft.VisualBasic.PowerPacks.Vs, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
    That's when I realized that the application had an OvalShape from the Microsoft.VisualBasic.PowerPacks.

    So I installed VBPowerPacks 2.0 and 3.0, but still get the error. Apparently, the VB PowerPacks provided with Express 2008 ((microsoft.visualbasic.powerspacks.vs ) is different from the one available for download (microsoft.visualbasic.powerspacks).

    I'll read up on what is involved in distributing a VB.Net application, what "Copy Local" means, what the GAC is, and report back.

    Thank you.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Sep 2003
    Posts
    99

    Re: How to investigate "System.InvalidOperationException"?

    Solved the issue by copying the missing DLL in the application directory.

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

    Re: [RESOLVED] How to investigate "System.InvalidOperationException"?

    Good detective work.
    My usual boring signature: Nothing

  7. #7
    New Member
    Join Date
    Sep 2016
    Posts
    13

    Re: How to investigate "System.InvalidOperationException"?

    Someday Shaggy Hiker I will owe you a huge Margarita! I had this error - read the post - was able to download PowerPacks 2 and 3 to my 64x server - still had error researched - They now have a PowerPack 10.0. The moral of the story with Microsoft - don't expect consistency.

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

    Re: [RESOLVED] How to investigate "System.InvalidOperationException"?

    Wasn't me. Seems like Fredtheman solved his own problem. I might have nudged him in the right direction, or not. In any case it IS kind of funny that the lack of an Oval caused his program to go all pear-shaped.
    My usual boring signature: Nothing

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width