C# Process 类调用外部exe 程序 Stop Working 异常
1. 异常描述
2. 描述:
3. Stopped working
4.
5. 问题签名:
6. 问题事件名称:CLR20r3
7. 问题签名 01:phoenix_label.exe
8. 问题签名 02:2.0.1.5
9. 问题签名 03:529d9e4b
10. 问题签名 04:System
11. 问题签名 05:2.0.0.0
12. 问题签名 06:506bf4fc
13. 问题签名 07:3ad3
14. 问题签名 08:288
15. 问题签名 09:System.ComponentModel.Win32
16. OS 版本:6.1.7600.2.0.0.256.48
17. 区域设置 ID:2052
18.
19. 联机阅读隐私声明:
20. http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0804
21.
22. 如果无法获取联机隐私声明,请脱机阅读我们的隐私声明:
23. C:\windows\system32\zh-CN\erofflps.txt
原因是由于被调用的外部 exe 程序没有用AppDomain.CurrentDomain.BaseDirectory 根目录调用所需文件
解决方式
通过ProcessStartInfo.WorkingDirectory属性设置被调用程序初始执行目录.让被调用程序可以调用他需要的文件
private void OpenFile_list(object sender, EventArgs e)
{
ProcessStartInfo info = new ProcessStartInfo();
Button b = (Button)sender;
//info.WorkingDirectory = @"D:\ ";//被调用程序目录
Process p = new Process();
info.FileName=b.Tag.ToString();//程序路径
try
{
Process.Start(info);
}
catch (Exception we)
{
MessageBox.Show(this, we.Message);
return;
}
}