如何在WinRT App中使用Diagnostic

时间:2014-11-17 11:08:13

标签: c# winrt-xaml

我需要在Win store App中从OEM启动或运行Windows exe文件。

以下可以使用?我尝试但有错误,但为什么诊断是在框架中


   using System.Diagnostics;

   Process myProcess = new Process();

   try
    {
      myProcess.StartInfo.UseShellExecute = false;

      // here I point to the OEM windows exe file

      myProcess.StartInfo.FileName = "C:\\HelloWorld.exe";

      myProcess.StartInfo.CreateNoWindow = true;

      myProcess.Start();


     }
    catch (Exception e)
    {
       Console.WriteLine(e.Message);
     }

- 更新

@ Michal:
谢谢。此方法使用URI。 一个问题:

WinRT应用程序在启动后进入后台。如何让winRT应用程序不去后台?

还有其他方法吗?我需要将来自OEM的Exe集成到Win Store App中。

注意:

我想知道这是可以做的还是我做了一些不允许的事情?

如果我没有让我的情况更清楚,请告诉我我想念的是什么。

我试了但是没用。所以我的解决方案应该使用像Diagnostic这样的类似方法,但它可以是什么?

1 个答案:

答案 0 :(得分:0)

回收https://social.msdn.microsoft.com/Forums/windowsapps/en-US/0a822355-909f-44b4-9c79-cb986087fe27/after-launching-or-activate-an-app-the-main-app-goes-into-background?forum=winappswithcsharp

中的位

这是预期的行为,并没有好办法。启动文件或协议会切换到默认处理程序而不期望返回。

首先通过像这样的协议启动应用程序。由于您是一个侧面加载的应用程序,因此需要编写一个Brokered Windows运行时组件,以便正确使用桌面API并与桌面后端进行通信。

请参阅http://msdn.microsoft.com/en-us/library/windows/apps/dn630195.aspx

上的Brokered Windows运行时组件文档