Tuesday, January 29, 2013

Is it possible to launch a Silverlight 4 OOB application from a web page?

Is it possible to launch a Silverlight 4 OOB application from a web page?

I'm planning to build a download manager application and would like to be able to launch the application when a user clicks a button the site. The application would obviously already need to be installed on the client machine.

There are a few reasons why this needs to be written using Silverlight, but they're not really relevant to the question. I only mention it so that people don't suggest that I use another technology.

Answers & Comments...

Answer: 1

Yes. Here is an example: http://www.silverlight.net/content/samples/apps/facebookclient/sfcquickinstall.aspx

by : Michael S. Scherotterhttp://stackoverflow.com/users/27306

Answer: 2

I think that is not possible according to this post post 1 and to other post. But I don't know if MS will change that in the last version of SL 4

by : Sebastianhttp://stackoverflow.com/users/356609

Answer: 3

Doing a bit of a mash up from two other posts [1] and [2].

But of course this will only work for Windows not Mac. There you will have to fallback to the @michael-s-scherotter style solution.

private void Button_Click(object sender, RoutedEventArgs e) {     if (Application.Current.HasElevatedPermissions && System.Windows.Interop.ComAutomationFactory.IsAvailable)     {          string run = "\""%ProgramFiles%\\Microsoft Silverlight\\sllauncher.exe"\" /emulate:"Silverface.xap" /origin:\"http://www.silverlight.net/content/samples/apps/facebookclient/ClientBin/Silverface.xap\" /overwrite";         dynamic cmd = ComAutomationFactory.CreateObject("WScript.Shell");         cmd.Run(run, 1, true);      } } 
by : JProgrammerhttp://stackoverflow.com/users/1675

Answer: 4

I found a trick that launches the installed silverlight OOB from the silverlight app in-browser. Both applications should be singed and have the elevated trust.

  1. When a user installs the silverlight OOB App first time, retrive the path and argument values from the shortcut file of the OOB app on desktop. (ref: How I can use Shell32.dll in Silverlight OOB) If you know the the path and argument values, you can launch the OOB app using Com Object.

  2. Send the retrive the path and argument values to the silverlight App in-browser. (ref: http://msdn.microsoft.com/en-us/library/dd833063(v=vs.95).aspx)

  3. Store the path and argument values in a cookie.

  4. Now, the silverlight app in-browser is able to launch the silverlight OOB using the path and argument values in the cookie.

    using (dynamic shell = AutomationFactory.CreateObject("WScript.Shell")) { shell.Run(launchPath); }

I hope this trick is useful to you :)

by : user689072http://stackoverflow.com/users/689072




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog