Problem in opening external program using C#

Nov 15 2007 3:39 AM

Hello,

 

I’m developing non commercial software using Visual C#. In the software, by clicking a button I can open under DOS program, which is named “Linear”, using code bellow

 

System.Diagnostics.Process proc = new System.Diagnostics.Process();

                proc.StartInfo.FileName = "start";

                proc.StartInfo.Arguments = "Linear";

                proc.Start();

                proc.WaitForExit();

 

The Linear lives in the same folder with my software so I don’t use full path for calling Linear.

 

When I debug my software, the under DOS program could be called and no problem at all. Then, I made setup application of my software, install it in my computer and the software work smoothly.

 

The problem is when I install my software on other computers and I click the button to open the under DOS program, suddenly warning box occurs with message bellow

 

///

See the end of this message for details on invoking

just-in-time (JIT) debugging instead of this dialog box.

 

************** Exception Text **************

System.ComponentModel.Win32Exception: The system cannot find the file specified

   at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)

   at System.Diagnostics.Process.Start()

   at Fondamen.Run.button3_Click(Object sender, EventArgs e)

   at System.Windows.Forms.Control.OnClick(EventArgs e)

   at System.Windows.Forms.Button.OnClick(EventArgs e)

   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)

   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)

   at System.Windows.Forms.Control.WndProc(Message& m)

   at System.Windows.Forms.ButtonBase.WndProc(Message& m)

   at System.Windows.Forms.Button.WndProc(Message& m)

   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

 

 

************** Loaded Assemblies **************

mscorlib

    Assembly Version: 2.0.0.0

    Win32 Version: 2.0.50727.832 (QFE.050727-8300)

    CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll

----------------------------------------

Fondamen

    Assembly Version: 1.0.0.0

    Win32 Version: 1.0.0.0

    CodeBase: file:///C:/Program%20Files/Institute%20Technology%20of%20Bandung/Setup%20Fondamen/Fondamen.exe

----------------------------------------

System.Windows.Forms

    Assembly Version: 2.0.0.0

    Win32 Version: 2.0.50727.832 (QFE.050727-8300)

    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll

----------------------------------------

System

    Assembly Version: 2.0.0.0

    Win32 Version: 2.0.50727.832 (QFE.050727-8300)

    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll

----------------------------------------

System.Drawing

    Assembly Version: 2.0.0.0

    Win32 Version: 2.0.50727.832 (QFE.050727-8300)

    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll

----------------------------------------

System.Configuration

    Assembly Version: 2.0.0.0

    Win32 Version: 2.0.50727.832 (QFE.050727-8300)

    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll

----------------------------------------

System.Xml

    Assembly Version: 2.0.0.0

    Win32 Version: 2.0.50727.832 (QFE.050727-8300)

    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll

----------------------------------------

Accessibility

    Assembly Version: 2.0.0.0

    Win32 Version: 2.0.50727.42 (RTM.050727-4200)

    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll

----------------------------------------

 

************** JIT Debugging **************

To enable just-in-time (JIT) debugging, the .config file for this

application or computer (machine.config) must have the

jitDebugging value set in the system.windows.forms section.

The application must also be compiled with debugging

enabled.

 

For example:

 

<configuration>

    <system.windows.forms jitDebugging="true" />

</configuration>

 

When JIT debugging is enabled, any unhandled exception

will be sent to the JIT debugger registered on the computer

rather than be handled by this dialog box.

///

 

I don’t know wheter it is caused by different environment variables or not. Even, if it is caused by different environment variables, I don’t know how to cope this. Please give me solution. Thank you before.

 

Andhika Sahadewa


Answers (2)