1

Now I want to launch a Windows 8 Metro App by a C# form application, but it's hard for me to find the right way...

I had tried these ways(I had installed the Metro App and registered a protocol):

1.

var success = await Windows.System.Launcher.LaunchUriAsync(new Uri("TestContent"));

In the "TestContent" above, I tried the protocol name registered on my computer and the Metro App's name, but the same error "Access Denied" occurred.

2.

            Process p = new Process();
            p.StartInfo.FileName = "ProtocolName://";
            p.Start();

This time the Metro App only showed the splash screen but didn't launch the whole program.

Any ideas?

Thank you in advance.

2015/10/01 ADD:

After Reading this question:

[link]stackoverflow.com/questions/18787609/…

I think it is impossible to run a metro app from a windows form.

CzeRen
  • 11
  • 4

3 Answers3

0

The right format to launch is :

 Uri uri = new Uri("protocolname://anything");
   await Windows.System.Launcher.LaunchUriAsync(uri);

And, Make sure that you're doing that from the foreground app, i.e. Not Background Task or a Toast notification or Tile .. etc.

Nasser AlNasser
  • 1,725
  • 2
  • 11
  • 12
0

After Reading this question:

C# Mixing WinRT and Windows Forms

I think it may be impossible to run a metro app from a windows form.

But when I try the code below :

            Process p = new Process();
            p.StartInfo.FileName = @"BINGMAPS://";
            p.Start();

The BINGMAPS runs normally.

Did I miss any necessary setting in the Metro App?

Community
  • 1
  • 1
CzeRen
  • 11
  • 4
0

First you need your app to handle protocol activation and then in App.xaml.cs in OnActivated event handle it to launch the first page or whatever page you want to call in Metro app. In C# form application using javascript set the current page content as the metro app. It will work.