• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 282
  • Last Modified:

.net application crashes when starting using Process.Start()

Hello,

I'm trying to launch a Winforms .NET Application (App1) that I created from another Winforms application (App2)  using Process.Start().  But sometime the application (App1) crashes on startup.   This never happens when I directly run App1.


When I look in the event log, I see this error message: Faulting application (App1) faulting module kernel32.dll, version 5.1.2600.5781.

I tried googling this but I didn't find anything that helped me.

Thanks
0
OFGemini
Asked:
OFGemini
  • 2
  • 2
  • 2
1 Solution
 
käµfm³d 👽Commented:
Can you post an example of the arguments you pass to Process.Start? It sounds like App1 has an unhandled exception.
0
 
OFGeminiAuthor Commented:
Hello,

Here is how I start App1.

Dim pathToApp1 As String = Path.Combine(Application.StartupPath, "App1.exe")
Process.Start(pathToApp1 )

I don't think its an issue w/ App1, b/c when I start App1 directly there is no problem.

Thanks

0
 
käµfm³d 👽Commented:
And there are no command-line arguments to App1?
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Check to see if that file exists first and also try setting the WorkingDirectory:
Dim pathToApp1 As String = Path.Combine(Application.StartupPath, "App1.exe")
        If File.Exists(pathToApp1) Then
            Dim P As New Process
            P.StartInfo.FileName = pathToApp1
            P.StartInfo.WorkingDirectory = Path.GetDirectoryName(pathToApp1)
            P.Start()
        Else
            MessageBox.Show("App1 not found!")
        End If

Open in new window

0
 
OFGeminiAuthor Commented:
Idle Mind, I'll try that, but what's the difference between your code and my code? Why does setting the workingDirectory make a difference?
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
The 'Else' block is just a troubleshooting aid.

The WorkingDirectory() basically sets the current folder so that the executable can find any external local files that it expects to find in the same folder as the application.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now