vb.net program launchs and then closes automatically

I have developed a vb.net program which when run from a shortcut works fine, however when I run it through an older vb6.exe which uses the winapi Shell Execute function, the program briefly appears on the screen and then closes.   This also happens with a piece of third party software that is setup to run this program.  
Developed in Visual Studio 10, vb.net, this happens on Windows 7 and Xp workstations.  The program is configured as a Windows Form Application.
Would appreciate any help

vb6 code that does the shell to the vb.net exe
' First, create a known, temporary HTML file
exeName = Space(255)

retval = FindExecutable(FileName, Dummy, exeName)
exeName = Trim(exeName)

' If an application is found, launch it!
If retval <= 32 Or IsEmpty(exeName) Or Err Then  ' Error
    LaunchFile = False
Else
    FileName = quo(FileName) 'put quotes around the item
    retval = ShellExecute(frmIcon.hwnd, "open", Trim$(exeName), FileName, Dummy, 5)
    If Err <> 0 Then
        MsgBox "Unable to run program <" & exeName & "> and launch file <" & FileName & "> RetVal=<" & CStr(retval) & "> Error=<" & Error$ & ">"
    Else
        LaunchFile = True
    End If
End If
LVL 3
nobleoneAsked:
Who is Participating?
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Why is it using Sub Main()?  If you need an earlier entry point, use the Application.Startup() event.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
What is in "Dummy"?  You may need to pass in the working directory instead (often the path to the executable itself) for the app to work correctly.
0
 
nobleoneAuthor Commented:
Dummy is empty string...good point, I am going to try changing that and see if it works...will get back to you
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
nobleoneAuthor Commented:
I solved the problem....the code was using application.run to run the first form from the  Sub Main used on startup as recommended in reading I did.  When run from a shortcut on desktop no problem, when shelled in any way, causes the program to self terminate.  I changed this to  form.showdialog method and it solved the problem.
0
 
nobleoneAuthor Commented:
vb6 conversion is why,   had about 800 properties, ocx , etc changes, definitely a learning experience...but vb.net is much better than the old vb6..thats for sure...did not know about the application.startup...I've been a sub main guy from years back...suspect that would have solved this problem also.  
0
 
nobleoneAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for nobleone's comment http:/Q_27414103.html#37104441

for the following reason:

was not the solution, but appreciated the very prompt input
0
 
nobleoneAuthor Commented:
mistake in the clicking...I wanted to close and award to idle_mind...was on my comment when I clicked close by accident, can you please award him the points...thanks
0
 
nobleoneAuthor Commented:
Not the exact solution, but would have solved the issue also
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.