Process.Start() 使用 .netcf-3.5 在 CE5 中打开 .exe。 Win32异常
希望这个问题能够得到解答。基本上,我试图从我创建的应用程序中打开一个可执行文件,该应用程序使用.net紧凑框架3.5在unitech条形码扫描仪上的Windows ce5上运行。我在尝试此操作时包含了一段代码。
每次我通过 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;
}
}
}
Hoping this question will get answered. Basically I am attempting to open an executable file from within an application I have created which runs on windows ce5 on a unitech barcode scanner using the .net compact framework 3.5. I have included a snippet of code where I attempt this.
Each time I debug the app via VS2008 I am getting a Win32Exception but with no further details (with or without the try catch statement). It does not tell me what the exception is nor does it provide an error code.
Here is the code I am using to try to start the process. Can you see anything wrong with it that may be causing an error? I have double and triple checked the filename and also the directory where it is stored so it is not that.
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;
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我看到两个问题。首先,CE 需要完全限定路径,因此
processStartInfo.FileName
应该类似于此其次,CE 没有工作目录的概念,因此删除对设置它的调用。
我也有点担心路径的
\bin\debug\
部分。 Studio 不会部署到设备上的bin\debug\
文件夹。它在 PC 上构建为一个,但在目标设备上,唯一的方式就是手动设置它。这让我认为您需要检查设备上的应用程序路径。I see two problems. First, CE requires fully qualified paths, so the
processStartInfo.FileName
should be something like thisSecond, CE has no concept of a WorkingDirectory, so remove the call to set it.
I'm also a little concerned about the
\bin\debug\
part of your path. Studio doesn't deploy to abin\debug\
folder on the device. It build to one on the PC, but on the target device the only way it would be there is if you manually set it. This leads me to think you need to check your on-device applicatin path.