开发者

Launch Silverlight Out of Browser App Programmatically

I am trying to use SLLAUNCHER.EXE to launch an SL Out-of-Browser App that is installed. The MyApp startup icon on the desktop just disappears after I run the below. If I try it without the overwrite switch nothing happens.

I am using this article as a guide:

http://timheuer.com/blog/archive/2010/03/25/using-sllauncher-for-silent-install-silverlight-application.aspx

Any suggestions would be appreciated.

    static void Main(string[] args)
    {
        string sllauncherPath = string.Format("{0}\\Microsoft Silverlight\\sllaun开发者_如何学Ccher.exe",
       Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles));

        string originUri = @"http://localhost:52878/ClientBin/MyApp.xap";
        string xap = "MyApp.xap";
        string arg = string.Format(@"/emulate:""{0}"" /origin:""{1}""  /overwrite", xap, originUri);

        var startInfo = new ProcessStartInfo
        {
            CreateNoWindow = false,
            UseShellExecute = false,
            RedirectStandardOutput = false,
            FileName = sllauncherPath,
            Arguments = arg
        };

       var process = Process.Start(startInfo))

    }


Are You using 64bit machine? http://social.msdn.microsoft.com/Forums/en-US/silverlightcontrols/thread/abedb9dc-d471-4d82-8a20-45f98671cac9

Could allso help: This is how I do restart from within my SL OOB apps after I detect update has completed:

''put this in your App.xaml.vb[.cs] and call DoRestart
Public Shared Sub DoRestart()
    StartAgain()
    Application.Current.MainWindow.Close()
End Sub
Public Shared Sub StartAgain()
    If Not [String].IsNullOrEmpty(GetSLLauncherCommand) Then
        Using shell = AutomationFactory.CreateObject("WScript.Shell")
            shell.Run(GetSLLauncherCommand)
        End Using
    End If
End Sub
Public Shared Function GetSLLauncherCommand() As String
    Dim desktopPath As String
    Dim SLLauncherCommand As String = ""
    Using wShell As Object = AutomationFactory.CreateObject("WScript.Shell")
        desktopPath = wShell.SpecialFolders("Desktop")
    End Using
    Using shell As Object = AutomationFactory.CreateObject("Shell.Application")
        Dim DesktopFolder As Object = shell.[NameSpace](desktopPath)
        Dim DesktopItems As Object = DesktopFolder.Items()
        For Each item In DesktopItems
            If item.IsLink Then 'this is a shurtcut
                Dim fileName As String = item.Name.ToLower()

                If fileName.Contains("!!!<PART OF YOUR SL APPS SHORCUT NAME>!!!!") Then
                    Dim link = item.GetLink()
                    SLLauncherCommand = """" & Convert.ToString(link.Path) & """ " & Convert.ToString(link.Arguments)
                End If
            End If
        Next
    End Using
    Return SLLauncherCommand
End Function

You could try adapt the code for Your non-SL app!

THT

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜