Solved

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

Posted on 2011-09-13
6
268 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 74

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 74

Expert Comment

by:käµfm³d 👽
ID: 36530034
And there are no command-line arguments to App1?
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Visual Studio installation 5 39
Problem to Popup 2 53
Hovering effect 9 30
Make all values in arrayist to titlecase+vb.net 23 14
A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now