Home All Groups Group Topic Archive Search About

Application.Run Problem

Author
10 Mar 2006 5:01 PM
rajendra.mishra
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.Current =
System.Windows.Forms.Cursors.Default
Application.Run(New ApplicationContext(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 ArgumentoutofRange
Exception at ' Application.Run(New ApplicationContext(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

Author
10 Mar 2006 5:23 PM
Chris
rajendra.mis***@gmail.com wrote:
Show quoteHide quote
> 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.Current =
> System.Windows.Forms.Cursors.Default
>  Application.Run(New ApplicationContext(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 ArgumentoutofRange
> Exception at ' Application.Run(New ApplicationContext(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
>

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
Author
10 Mar 2006 7:21 PM
rajendra.mishra
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
Author
10 Mar 2006 6:40 PM
raulavi
had the same prob you describe... but it was on
Private Sub me_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

some times it just crashed after displaying correctly...meaning 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.

Show quoteHide quote
"rajendra.mis***@gmail.com" wrote:

> 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.Current =
> System.Windows.Forms.Cursors.Default
>  Application.Run(New ApplicationContext(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 ArgumentoutofRange
> Exception at ' Application.Run(New ApplicationContext(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
>
>
Author
10 Mar 2006 8:52 PM
Armin Zingler
<rajendra.mis***@gmail.com> schrieb
Show quoteHide quote
> 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.Current =
> System.Windows.Forms.Cursors.Default
> Application.Run(New ApplicationContext(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
> ArgumentoutofRange Exception at ' Application.Run(New
> ApplicationContext(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.


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
Author
10 Mar 2006 11:39 PM
rajendra.mishra
on doing a quick watch it shows the following error

    Application.Run(g_frmMain)    Run-time exception thrown :
System.InvalidOperationException - It is invalid to start a second
message loop on a single thread. Use Application.RunDialog 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
Author
11 Mar 2006 1:46 AM
Dennis
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


Show quoteHide quote
"rajendra.mis***@gmail.com" wrote:

> on doing a quick watch it shows the following error
>
>     Application.Run(g_frmMain)    Run-time exception thrown :
> System.InvalidOperationException - It is invalid to start a second
> message loop on a single thread. Use Application.RunDialog 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
>
>