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;
}
}
}
I see two problems. First, CE requires fully qualified paths, so the
processStartInfo.FileNameshould 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.