简体   繁体   English

Process.Start()使用.netcf-3.5在CE5中打开.exe。 Win32Exception

[英]Process.Start() to open .exe in CE5 using .netcf-3.5. Win32Exception

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. 基本上我试图从我创建的应用程序中打开一个可执行文件,该应用程序在使用.net紧凑框架3.5的unitech条形码扫描器上的windows ce5上运行。 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). 每次我通过VS2008调试应用程序时,我都会收到Win32Exception,但没有进一步的细节(有或没有try catch语句)。 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.FileName should be something like this 首先,CE需要完全限定的路径,因此processStartInfo.FileName应该是这样的

processStartInfo.FileName = 
@"\Flash Storage\CompoundingManagementScannerSuite\Applications\AssetTrackingScanner\AssetTrackingScanner\AssetTrackingScanner.exe"; 

Second, CE has no concept of a WorkingDirectory, so remove the call to set it. 其次,CE没有WorkingDirectory的概念,所以删除调用来设置它。

I'm also a little concerned about the \\bin\\debug\\ part of your path. 我也有点担心路径的\\bin\\debug\\部分。 Studio doesn't deploy to a bin\\debug\\ folder on the device. Studio不会部署到设备上的bin\\debug\\文件夹。 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. 它在PC上构建为一个,但在目标设备上,唯一的方法就是手动设置它。 This leads me to think you need to check your on-device applicatin path. 这使我认为您需要检查您的设备应用程序路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM