2011-08-23 84 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

相關問題