Application.Run Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rajendra.mishra@gmail.com

    Application.Run Problem

    Hi...
    I have a windows vb.net application. The StatupObject is a Module
    'modMain'.
    In the main sub routine i have the following
    g_frmMain = New formVMMain
    System.Windows. Forms.Cursor.Cu rrent =
    System.Windows. Forms.Cursors.D efault
    Application.Run (New ApplicationCont ext(g_frmMain))


    There is a progress bar in the form which starts everytime a file in a
    particular folder is updated.so whenever the file is updated the
    progress bar is initialised and shown in the main Form. The application
    works fine sometimes but at other times it gives an ArgumentoutofRa nge
    Exception at ' Application.Run (New ApplicationCont ext(g_frmMain)) ' this
    line. 'Index was out of Range. Must be non negative and less than the
    size of the collection.'

    Any Help will be appreciated.

    Raj

  • Chris

    #2
    Re: Application.Run Problem

    rajendra.mishra @gmail.com wrote:[color=blue]
    > Hi...
    > I have a windows vb.net application. The StatupObject is a Module
    > 'modMain'.
    > In the main sub routine i have the following
    > g_frmMain = New formVMMain
    > System.Windows. Forms.Cursor.Cu rrent =
    > System.Windows. Forms.Cursors.D efault
    > Application.Run (New ApplicationCont ext(g_frmMain))
    >
    >
    > There is a progress bar in the form which starts everytime a file in a
    > particular folder is updated.so whenever the file is updated the
    > progress bar is initialised and shown in the main Form. The application
    > works fine sometimes but at other times it gives an ArgumentoutofRa nge
    > Exception at ' Application.Run (New ApplicationCont ext(g_frmMain)) ' this
    > line. 'Index was out of Range. Must be non negative and less than the
    > size of the collection.'
    >
    > Any Help will be appreciated.
    >
    > Raj
    >[/color]

    Your problem is not on the application.run object, it's in your form
    formVMMain. Tell the compiler to break on all exceptions (Debug ->
    Exceptions) and then hopefully it will break where the actual exception
    is happening.

    Chris

    Comment

    • raulavi

      #3
      RE: Application.Run Problem


      had the same prob you describe... but it was on
      Private Sub me_Paint(ByVal sender As Object, ByVal e As
      System.Windows. Forms.PaintEven tArgs) Handles MyBase.Paint

      some times it just crashed after displaying correctly...mea ning the form was
      perfectly displayed/working but, when I did call another window and back then
      it crashed.
      might help some one if not you.

      "rajendra.mishr a@gmail.com" wrote:
      [color=blue]
      > Hi...
      > I have a windows vb.net application. The StatupObject is a Module
      > 'modMain'.
      > In the main sub routine i have the following
      > g_frmMain = New formVMMain
      > System.Windows. Forms.Cursor.Cu rrent =
      > System.Windows. Forms.Cursors.D efault
      > Application.Run (New ApplicationCont ext(g_frmMain))
      >
      >
      > There is a progress bar in the form which starts everytime a file in a
      > particular folder is updated.so whenever the file is updated the
      > progress bar is initialised and shown in the main Form. The application
      > works fine sometimes but at other times it gives an ArgumentoutofRa nge
      > Exception at ' Application.Run (New ApplicationCont ext(g_frmMain)) ' this
      > line. 'Index was out of Range. Must be non negative and less than the
      > size of the collection.'
      >
      > Any Help will be appreciated.
      >
      > Raj
      >
      >[/color]

      Comment

      • rajendra.mishra@gmail.com

        #4
        Re: Application.Run Problem

        Hi Chris/raulavi...

        Thanks for the prompt replies

        I am not able to catch the exception except at the Application.Run . The
        BreakPoints at FormvmMain and elsewhere do not come up...it goes to
        this line and throws it...If i handle the exception at Application.run
        it goes to catch...but then the application exits itself.

        Raj

        Comment

        • Armin Zingler

          #5
          Re: Application.Run Problem

          <rajendra.mishr a@gmail.com> schrieb[color=blue]
          > Hi...
          > I have a windows vb.net application. The StatupObject is a Module
          > 'modMain'.
          > In the main sub routine i have the following
          > g_frmMain = New formVMMain
          > System.Windows. Forms.Cursor.Cu rrent =
          > System.Windows. Forms.Cursors.D efault
          > Application.Run (New ApplicationCont ext(g_frmMain))
          >
          >
          > There is a progress bar in the form which starts everytime a file in
          > a particular folder is updated.so whenever the file is updated the
          > progress bar is initialised and shown in the main Form. The
          > application works fine sometimes but at other times it gives an
          > ArgumentoutofRa nge Exception at ' Application.Run (New
          > ApplicationCont ext(g_frmMain)) ' this line. 'Index was out of Range.
          > Must be non negative and less than the size of the collection.'
          >
          > Any Help will be appreciated.[/color]


          What does the callstack window show when the exception occurs? Please
          Include the "non-user code" (or "external code") in the window's context
          menu.


          Armin

          Comment

          • rajendra.mishra@gmail.com

            #6
            Re: Application.Run Problem

            on doing a quick watch it shows the following error

            Application.Run (g_frmMain) Run-time exception thrown :
            System.InvalidO perationExcepti on - It is invalid to start a second
            message loop on a single thread. Use Application.Run Dialog or
            Form.ShowDialog instead.

            while the popup message shows the following
            "
            Index was out of range. Must be non-negative and less than the size of
            the collection.
            Paramater name: index
            "
            I have tried using Form.showdialog it gives me the same...for 10 times
            it will work fine but sometime it wont...

            Raj

            Comment

            • Dennis

              #7
              Re: Application.Run Problem

              Why don't you start your program (Vb.Net 2003) from your main sub like;
              g_frmMain.Show
              Applicaton.Run

              Why are you using the new application context? Is this a VB.Net 2005 thing
              (I use only 2003 due the problems with 2005 that I've read in this newsgroup).

              --
              Dennis in Houston


              "rajendra.mishr a@gmail.com" wrote:
              [color=blue]
              > on doing a quick watch it shows the following error
              >
              > Application.Run (g_frmMain) Run-time exception thrown :
              > System.InvalidO perationExcepti on - It is invalid to start a second
              > message loop on a single thread. Use Application.Run Dialog or
              > Form.ShowDialog instead.
              >
              > while the popup message shows the following
              > "
              > Index was out of range. Must be non-negative and less than the size of
              > the collection.
              > Paramater name: index
              > "
              > I have tried using Form.showdialog it gives me the same...for 10 times
              > it will work fine but sometime it wont...
              >
              > Raj
              >
              >[/color]

              Comment

              Working...