Application.Run Error

G

Guest

I start my applicaiton from sub Main as follows:

<STAThread()>Public Sub Main()
Dim MainForm As frm_Main = New frm_Main
Application.Run(MainForm)
End Sub

In the MainForm, I show a Progress Form as follows:

Private Sub get_Listing()
Dim prform as New ProgBarForm (this is a form I created with a cancel button)
prform.Show()
dim finished as boolean
While not finished
.....Do Something to get my listing items
Application.DoEvents
'Cancel is a property in prform set to True if Cancel button is clicked
.....If prform.Cancel then finished=True
wend
prform.close
End Sub

I get an error in sub main on the Application.Run Line stating that an error
has occured in an external component. However, if I start my application by
setting my Mainform as the Start-Up form then I don't get the error. Only
when I start my application from sub main do I get the error. I have tried
showing Mainform from sub main using MainForm.ShowDialog and still get the
same error.
 
G

Guest

The progress form is declared in your main form I take it.

Do you call this progress dialog more than once?

I've noticed that you aren't disposing of the progress form when you close it.

What code, if any do you have in your progress form? Behind the 'cancel'
button should only be 'Me.Close()' & nothing else.

What is the process of listing things you are performing whilst the progress
form is shown? Are you calling another sub?

Awaiting your response.
 
G

Guest

See my response below.

Crouchie1998 said:
The progress form is declared in your main form I take it.
Yes, it's delcared in the Module that contains the Sub Main
Do you call this progress dialog more than once? No.

I've noticed that you aren't disposing of the progress form when you close it.
I added that after the prform.Close statement below (prform.Dispose) but get
the same result.
What code, if any do you have in your progress form? Behind the 'cancel'
button should only be 'Me.Close()' & nothing else.
The only code behind the cancel button is a statement to set a property
(prform.Cancel to True. I don't close the form here but instead rely on the
prform.close in my code below.
What is the process of listing things you are performing whilst the progress
form is shown? Are you calling another sub?
Yes, I am getting Files and File information from a sub I call Get_FileInfo
but this works fine when I use the mainform as startup instead of sub Main.
 
C

Chris Dunaway

Wrap the call to Application.Run in a try block. When the exception
hits, log the exception and it's stack trace. Perhaps that would give
some clues as to what is happening.

You might also try stepping through the code to see if you can narrow
down where the exception is occurring.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top