Solved

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

Posted on 2011-09-13
6
270 Views
Last Modified: 2012-05-12
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
Comment
Question by:OFGemini
  • 2
  • 2
  • 2
6 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 36529864
Can you post an example of the arguments you pass to Process.Start? It sounds like App1 has an unhandled exception.
0
 

Author Comment

by:OFGemini
ID: 36529978
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
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 36530034
And there are no command-line arguments to App1?
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 36530184
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
 

Author Comment

by:OFGemini
ID: 36530437
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
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 36530450
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question