2011-08-23 89 views
7

我试图使用SLLAUNCHER.EXE启动已安装的SL浏览器外应用程序。运行以下代码后,桌面上的MyApp启动图标就消失了。如果我尝试没有覆盖开关没有任何反应。以编程方式启动Silverlight退出浏览器应用程序

我使用这篇文章作为指导:

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

任何建议,将不胜感激。

static void Main(string[] args) 
    { 
     string sllauncherPath = string.Format("{0}\\Microsoft Silverlight\\sllauncher.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)) 

    } 
+1

它工作还是有问题吗? – kenny

+0

我试图让同样的事情工作。看起来Silverlight 4中可能存在一个错误,导致sllauncher.exe无提示失败。无论如何,我会继续研究它。也许有一个解决方法。 https://connect.microsoft.com/VisualStudio/feedback/details/575052/sllauncher-exe-fails-silently-and-runs-nothing-with-emulate-option –

+0

我试图用我的应用程序完全相同的代码在希望我可以简单地使用外部应用程序以编程方式启动安装在同一个盒子上的OOB silverlight应用程序,并获得相同的结果。我的OOB应用程序的桌面快捷方式消失了,OOB silverlight的窗口显示出来了。我在我的托管版本中传递了init参数,导致它不会加载OOB,所以我不是100%,它的加载还没有像预期的那么好,但是窗口在窗口标题栏中弹出预期的标题。 –

回答

0

您使用的是64位机器吗? http://social.msdn.microsoft.com/Forums/en-US/silverlightcontrols/thread/abedb9dc-d471-4d82-8a20-45f98671cac9

莫非allso帮助: 这是我做的是如何从我的SL OOB应用程序内重新启动后,我发现更新已完成:

''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 

你可以尝试适应代码用于非-SL应用程序!

THT

相关问题