我正在尝试编写一个简单的主菜单应用程序,用户可以在其中单击按钮,然后它将启动已安装在Windows 10 IoT中的应用程序。 (它的" IoTCoreMediaPlayer" app作为样本)
这是我的代码:
private void Button_Click(object sender, RoutedEventArgs e)
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = @"C:\Data\USERS\DefaultAccount\AppData\Local\DevelopmentFiles\IoTCoreMediaPlayerVS.Debug_ARM.User\entrypoint\IoTCoreMediaPlayer.exe";
startInfo.Arguments = f;
Process.Start(startInfo);
}
然而,这不起作用,并给我以下错误:
System.NotImplementedException: 'The method or operation is not implemented.'
下:
using Media_Center;
namespace System.Diagnostics
{
internal class Process
{
internal static void Start(string v)
{
throw new NotImplementedException();
}
internal static void Start(ProcessStartInfo startInfo)
{
throw new NotImplementedException(); <===
}
}
}
有人可以告诉我我做错了什么吗? 感谢
答案 0 :(得分:2)
您可以参考此sample,其中演示了如何从其他UWP应用启动UWP应用。 在此示例中,您可以找到操作代码:
private async void RunMainPage_Click(object sender, RoutedEventArgs e)
{
await LaunchAppAsync("test-launchmainpage://HostMainpage/Path1?param=This is param");
}
private async void RunPage1_Click(object sender, RoutedEventArgs e)
{
await LaunchAppAsync("test-launchpage1://Page1/Path1?param1=This is param1¶m1=This is param2");
}
private async Task LaunchAppAsync(string uriStr)
{
Uri uri = new Uri(uriStr);
var promptOptions = new Windows.System.LauncherOptions();
promptOptions.TreatAsUntrusted = false;
bool isSuccess = await Windows.System.Launcher.LaunchUriAsync(uri, promptOptions);
if (!isSuccess)
{
string msg = "Launch failed";
await new MessageDialog(msg).ShowAsync();
}
}
设置技巧,在要启动的应用程序上指定Windows协议,并在LaunchApp URI中指定。
此外,如果要启动外部进程(exe),可以参考此ExternalProcessLauncher示例。