将命令行参数传递给OOB Silverlight 4应用程序

时间:2010-05-06 09:12:10

标签: silverlight silverlight-4.0 out-of-browser

我需要通过现有的WinForms应用程序启动Silverlight 4 OOB应用程序(使用System.Diagnostics.Process执行sllauncher.exe)。我希望有一些方法可以使sllauncher.exe接受并将命令行参数传递给OOB应用程序,但我无法弄明白。

3 个答案:

答案 0 :(得分:4)

Silverlight没有提供API来获取对命令行参数的访问权限。

这是WPF(也许是点击一次)将是更好的选择。

或者考虑存储需要在Silverlight应用程序启动时可访问的本地文件中传递的“数据”。

答案 1 :(得分:2)

您可以通过将网址传递到sllauncher.exe的{​​{1}}参数来解决此问题,例如:

/origin

在Silverlight代码中,您可以通过

访问sllauncher.exe /overwrite /emulate:c:\temp\Hello.xap /origin:c:\temp\Hello.xap?key=value参数的值
/origin

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

不幸的是,因为URI是Application.Current.Host.Source.OriginalString // file:///C:/temp/Hello.xap%3Fkey=value URI,所以查询参数不会存储在file:///中。这也可能为“滥用”创造机会 - 我的有限经验是Source.QueryString将在sllauncher 传递给某些的内容看起来像路径或URI时启动。

答案 2 :(得分:0)

是的,它可能在silverlight中

dynamic cmd=AutomationFactory.CreateObject("Shell.Application");
cmd.ShellExecute(@path_of_ur_exe,null,null,null,1);
相关问题