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.

- 187,081
- 35
- 232
- 306

- 460
- 4
- 12
3 Answers
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.

- 58,954
- 17
- 116
- 143
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.

- 9,841
- 6
- 35
- 34