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

发布于 2024-12-02 21:20:32 字数 1656 浏览 1 评论 0原文

希望这个问题能够得到解答。基本上,我试图从我创建的应用程序中打开一个可执行文件,该应用程序使用.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦在深巷 2024-12-09 21:20:33

我看到两个问题。首先,CE 需要完全限定路径,因此 processStartInfo.FileName 应该类似于此

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

其次,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 this

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.

I'm also a little concerned about the \bin\debug\ part of your path. Studio doesn't deploy to a bin\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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文