473,508 Members | 2,303 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.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

Mar 10 '06 #1
6 4467
ra*************@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


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
Mar 10 '06 #2

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.

"ra*************@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

Mar 10 '06 #3
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

Mar 10 '06 #4
<ra*************@gmail.com> schrieb
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

Mar 10 '06 #5
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

Mar 10 '06 #6
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
"ra*************@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

Mar 11 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
2745
by: Timothy Shih | last post by:
Hi, I am having a freezing issue with my application. My application serves several remotable objects, all of which must be initialized before their use. Furthermore, some of them depend on each...
9
2799
by: Rajat Tandon | last post by:
Hello there, I am relatively new to the newsgroups and C#. I have never been disappointed with the groups and always got the prompt replies to my queries.This is yet another strange issue, I am...
8
2740
by: Pete Wittig | last post by:
Hello, I am wondering if it is possible to create a networked application with C# that is seen as a windows user. For example, if Bob logged onto windows and then started the application, any...
1
2568
by: CES | last post by:
All, Could someone please point me to a step by step resource on setting up a ..net Web Application on IIS. I'm having a problem setting up IIS to except a new Web Application. I'm deploying...
9
2438
by: William LaMartin | last post by:
I have a problem, mentioned here before, of Session and Application variables disappearing at one site but not at others or on my development computer. The problem is illustrated by an example...
5
20417
by: Lars-Erik Aabech | last post by:
Hi! Guess it's my day again.. Tried to deploy a test release of a new asp.net web today, and got a terrible error. The web is running swell on three development computers, but when it's copied...
9
2754
by: Graham | last post by:
I have been having some fun learning and using the new Controls and methods in .Net 2.0 which will make my life in the future easier and faster. Specifically the new databinding practises and...
20
2668
by: Peter Oliphant | last post by:
How does one launch multiple forms in an application? Using Photoshop as an example, this application seems to be composed of many 'disjoint' forms. Yet, they all seem somewhat 'active' in...
13
4720
by: Kevin Liebowicz | last post by:
Yes, I wasted the past two days trying to fix this. Yes, this is on a Win2003 Server. Yes, this machine is a domain controller. Yes, I seen the dozens of KB articles like this one:...
6
2248
by: Tony Johansson | last post by:
Hello! We have a C#.ASP.NET application that runs on a IIS 6. The application contains actually several asp pages but there is no GUI. The application receive an xml file that is processed....
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7123
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7382
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
5052
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3193
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3181
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1556
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.