Solved

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

Posted on 2011-09-13
6
272 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 86

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 86

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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
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 …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 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