5

I need to launch a Silverlight 4 OOB app through an existing WinForms application (using System.Diagnostics.Process to execute sllauncher.exe). I was hoping there would be some way to make sllauncher.exe accept and pass on command line args to the OOB application, but I couldn't figure it out.

AnthonyWJones
  • 187,081
  • 35
  • 232
  • 306
lo5
  • 460
  • 4
  • 12

3 Answers3

4

There's not an API provided by Silverlight to gain access to the command-line arguments.

This is where WPF (and maybe click-once) would be a better option.

Or consider storing the "data" needed to be passed in a local file accessible by the Silverlight application when it starts.

WiredPrairie
  • 58,954
  • 17
  • 116
  • 143
3

You can work around this by passing an URL to sllauncher.exe's /origin parameter, e.g.:

sllauncher.exe /overwrite /emulate:c:\temp\Hello.xap /origin:c:\temp\Hello.xap?key=value.

In your Silverlight code, you can access the value of the /origin parameter via

Application.Current.Host.Source.OriginalString 
// file:///C:/temp/Hello.xap%3Fkey=value

(msdn: http://msdn.microsoft.com/en-us/library/system.windows.interop.silverlighthost.source(v=vs.96).aspx)

Unfortunately, because the URI is a file:/// URI, the query parameters are not stored in Source.QueryString. This might also create opportunities, however, for "abuse" - my limited experience is that sllauncher will start if what is passed to /origin somewhat looks like a path or URI.

skrebbel
  • 9,841
  • 6
  • 35
  • 34
0

yah its possible in silverlight

dynamic cmd=AutomationFactory.CreateObject("Shell.Application");
cmd.ShellExecute(@path_of_ur_exe,null,null,null,1);
GSerg
  • 76,472
  • 17
  • 159
  • 346