Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a program with System.Diagnostics.Process.Start causes an Application Error

On my PC DWG files open with:

"C:\Program Files\AutoCAD LT 2007\acadlt.exe" "%1"

If I run this from the command line:

"C:\Program Files\AutoCAD LT 2007\acadlt.exe" "C:\Some Path\Test.dwg"

AutoCAD Lite open the DWG file.

Similarly if I open a command prompt and run the same exe with argument, it works fine.

However if I use

var proc = new System.Diagnostics.Process();
var info = new System.Diagnostics.ProcessStartInfo();

and then

info.FileName = "C:\Some Path\Test.dwg";
proc.StartInfo = info;
proc.Start();

or

info.FileName = "C:\Program Files\AutoCAD LT 2007\acadlt.exe";
info.Arguments= "C:\Some Path\Test.dwg"
proc.StartInfo = info;
proc.Start();

or

info.FileName = "cmd.exe";
info.Arguments= "C:\Program Files\AutoCAD LT 2007\acadlt.exe" "C:\Some Path\Test.dwg"
proc.StartInfo = info;
proc.Start();

I get the following error:


acadlt.exe - Application Error

The instruction at "0x01317c8c" referenced memory at "0x01317c8c". The memory could not be "read".

Click on OK to terminate the program Click on CANCEL to debug the program

OK Cancel


Incidentally the code works ok if I step through the code with the debugger.

Anyone know how I can use Process.Start to open this DWG?

like image 536
Andrew Roberts Avatar asked Mar 24 '26 07:03

Andrew Roberts


1 Answers

Make sure to have the correct working folder specified:

info.WorkingDirectory = "same path as current directory in cmd.exe";
like image 195
Dirk Vollmar Avatar answered Mar 25 '26 19:03

Dirk Vollmar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!