【发布时间】:2011-09-05 12:01:41
【问题描述】:
希望这个问题能得到解答。基本上,我试图从我创建的应用程序中打开一个可执行文件,该应用程序使用 .net compact framework 3.5 在 Unitech 条码扫描仪上的 windows ce5 上运行。我在其中尝试了一个 sn-p 代码。
每次我通过 VS2008 调试应用程序时,我都会收到 Win32Exception,但没有更多详细信息(有或没有 try catch 语句)。它没有告诉我异常是什么,也没有提供错误代码。
这是我用来尝试启动该过程的代码。你能看出它有什么问题可能导致错误吗?我已经两次和三次检查了文件名以及存储它的目录,所以不是这样。
private void CustomButtonEvent(object sender, EventArgs e)
{
string buttonName = ((Control)sender).Name;
ProcessStartInfo processStartInfo = new ProcessStartInfo();
buttonName = buttonName.Remove(0, 3);
buttonName = buttonName.Replace(' ', '_');
switch (buttonName)
{//todo need to open the different exe's here
case "End_Of_Line":
{
MessageBox.Show(@"No app behind this button yet.");
break;
}
case "Asset_Tracking":
{
processStartInfo.FileName = "AssetTrackingScanner.exe";
processStartInfo.WorkingDirectory = @"\Flash Storage\CompoundingManagementScannerSuite\Applications\AssetTrackingScanner\AssetTrackingScanner\bin\Debug";
try
{
Process.Start(processStartInfo);
}
catch (Exception f)
{
MessageBox.Show(f.ToString());
}
break;
}
case "Stock Take":
{
MessageBox.Show(@"No app behind this button yet.");
break;
}
case "Despatch":
{
MessageBox.Show(@"No app behind this button yet.");
break;
}
}
}
【问题讨论】:
-
设置工作目录时为什么不用盘符?
-
驱动器没有字母。所有目录都有名称而不是字母。为了仔细检查这一点,我运行了一个命令提示符并输入 cd A: 一直到 cd P: 并且它从未找到任何目录但是如果我输入 cd FlashStorage 它发现它没有问题。
-
您的程序是否与
AssetTrackingScanner.exe在同一个磁盘上? -
现在我正在通过 VS2008 部署应用程序,然后当我单击应该运行下一个应用程序的菜单选项时,我收到错误消息。我将尝试将可执行文件复制到同一个磁盘,然后查看错误是否仍然存在。我没想到这可能是因为我正在调试而不是直接运行可执行文件。如果这有什么不同,我会报告。谢谢
-
我将所有相关文件复制到闪存中,但不幸的是,错误仍然存在。如下: System.ComponentModel.Win32Exception:Win32Exception at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo processStartInfo) etc
标签: c# .net-3.5 windows-ce