72826

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

Question:

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.

Answer1:

I think that is not possible according to this post <a href="https://stackoverflow.com/questions/2958866/is-it-possible-to-launch-a-silverlight-4-oob-application-from-a-web-page" rel="nofollow">post 1</a> and to other <a href="https://stackoverflow.com/questions/2325647/launch-silverlight-out-of-browser-from-browser-post-installation" rel="nofollow">post</a>. But I don't know if MS will change that in the last version of SL 4

Answer2:

Doing a bit of a mash up from two other posts [<a href="http://forums.silverlight.net/forums/p/157670/355145.aspx" rel="nofollow">1</a>] and [<a href="http://timheuer.com/blog/archive/2010/03/25/using-sllauncher-for-silent-install-silverlight-application.aspx" rel="nofollow">2</a>].

But of course this will only work for Windows not Mac. There you will have to fallback to the <a href="https://stackoverflow.com/questions/2958866/is-it-possible-to-launch-a-silverlight-4-oob-application-from-a-web-page/2959043#2959043" rel="nofollow">@michael-s-scherotter</a> 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); } }

Answer3:

Yes. Here is an example: <a href="http://www.silverlight.net/content/samples/apps/facebookclient/sfcquickinstall.aspx" rel="nofollow">http://www.silverlight.net/content/samples/apps/facebookclient/sfcquickinstall.aspx</a>

Answer4:

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.

<ol><li>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: <a href="https://stackoverflow.com/questions/14541151/how-i-can-use-shell32-dll-in-silverlight-oob" rel="nofollow">How I can use Shell32.dll in Silverlight OOB</a>) If you know the the path and argument values, you can launch the OOB app using Com Object. </li> <li>Send the retrive the path and argument values to the silverlight App in-browser. (ref: <a href="http://msdn.microsoft.com/en-us/library/dd833063(v=vs.95).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/dd833063(v=vs.95).aspx</a>)</li> <li>Store the path and argument values in a cookie. </li> <li>Now, the silverlight app in-browser is able to launch the silverlight OOB using the path and argument values in the cookie.</li> </ol>

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

I hope this trick is useful to you :)

Answer5:

It is possible if you agree to install the app each time the user clicks on it.

You also should set the app to require elevated trust in its OOB settings.

Just uninstall the app on startup (for example, in main window constructor):

if (Application.Current.HasElevatedPermissions && Application.Current.InstallState == InstallState.Installed) { string launcherPath = string.Empty; using (dynamic shell = AutomationFactory.CreateObject("Shell.Application")) { string launcher64 = @"C:\Program Files (x86)\Microsoft Silverlight"; string launcher32 = @"C:\Program Files\Microsoft Silverlight"; dynamic folder64 = shell.NameSpace(launcher64); if (folder64 != null) { launcherPath = launcher64; } else { dynamic folder32 = shell.NameSpace(launcher32); if (folder32 != null) { launcherPath = launcher32; } } } using (dynamic shell = AutomationFactory.CreateObject("WScript.Shell")) { var origin = Application.Current.Host.Source.OriginalString; var launchCmd = string.Format(@"""{0}\sllauncher.exe"" /uninstall /origin:""{1}""", launcherPath, origin); shell.Run(launchCmd); } }

(the code for uninstall was taken from this post: <a href="http://www.wintellect.com/blogs/sloscialo/programmatically-uninstalling-silverlight-out-of-browser-application" rel="nofollow">http://www.wintellect.com/blogs/sloscialo/programmatically-uninstalling-silverlight-out-of-browser-application</a>)

Recommend

  • AngularJS filter out select option based on another selection
  • FreeImage on C#
  • Javafx: update TableCell
  • php mcrypt equivalent for sagepay on a windows server
  • How to deploy APPX to running Windows Phone Emulator?
  • How do I correctly setup a GKSession (Bluetooth) on iOS 6.1
  • How to install mysql from batch file?
  • Excel VBA: search a string to find the first non-text character
  • Cannot open include file 'boost/any.hpp' - Invalid argument in VS 2010
  • Visual c# Express Edition - can't get Acrobat pdf reader to work
  • unzip file using 7z in powershell
  • advanced filter excel with c#
  • convert .net 4.0 syntax OfType to .net 3.5
  • Saving file from JavaScript string without hitting server
  • C# Equivalent to this code
  • Custom Validator Angular 2
  • Why is this button causing my layout to break?
  • Azure Service Bus topics partitioning
  • Updating one element of a bound Observable collection
  • Launch powershell script from UWP app with FullTrustProcessLauncher class
  • How to create a custom Powershell operator?
  • Use New-AzureDeployment to deploy cloud service, But error occurs “The HTTP version specified is not
  • Where can I get Microsoft.DirectX.dll?
  • matlab crashes without dump file when using fopen for file
  • C# Report Renderer for SRSS 2008 R2 - Missing Parameter
  • Compress a file with GZipStream while maintaining its meta-data
  • powershell Get-Counter -ComputerName parameter on Windows 7
  • Xamarin MonoAndroid Azure mobile service InsertAsync
  • Private IP address in reserved subnet range
  • How To Customize ASP.NET Chart Databound To SqlDataSource
  • Validaiting emails with Net.Mail MailAddress
  • Can I have the cursor start on a particular column by default in jqgrid's edit mode?
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Circular dependency while pushing http interceptor
  • Linker errors when using intrinsic function via function pointer
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Proper folder structure for lots of source files
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • How does Linux kernel interrupt the application?