Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems using System.Diagnostics.Process.Start

Status
Not open for further replies.

JScannell

Programmer
Jan 9, 2001
306
US
Up until this morning, I had some VS2005 projects in the path:
C:\TanPgms - 25\

This morning I moved them to this path to align myself with the other developer here:
My Documents\Visual Studio 2005\Projects\TanPgms\Invoice2

When I execute this code in another project:
System.Diagnostics.Process.Start("invoice2.exe", s2).WaitForExit()

(BTW that application has a reference to the invoice2.exe program that is that new path of: My Documents\Visual Studio 2005\Projects\TanPgms\Invoice2\bin\debug), I get the following error:

System.NullReferenceException: Object reference not set to an instance of an object.
at BLLCls..ctor() in C:\TanPgms - 25\Invoice2\BLL.cs:line 78
at invoice1.Form1.Form1_Load(Object sender, EventArgs e) in C:\TanPgms - 25\Invoice2\Form1.cs:line 498
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()

Why is the old path still being referenced?

Thanks in advance,

Jerry Scannell
 

Typically when an exe can be run using just its name and not its path as well, it is because the exe's path is included in Windows' PATH variable. Try looking for this:

Start->Control Panel->System (Or: right-click on My Computer [Win XP] or Computer [Vista or Win 7]).

In the System Properties dialog, select the Advanced tab, then click the Environment Variables button at the bottom. Look at the Path variable under User variables and System variables and see if the old path is there and change it to the new path if it is.


Otherwise, check the app's settings for the old path, or maybe the registry.


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
That is mostly true. However, the other thing though is for VS2005 and VS2008 at least when no path is supplied and one is required the program will first check the startup directory. By default that will be the directory the current running program is in unless you specify differently in the program or shortcut you run it from.

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top