2009-08-11 118 views
2

我有幾個用戶在使用Silverlight應用程序,這些應用程序在發佈新版本時沒有收到更新。這不是假設是自動的,或者我錯過了某個選項?我也開始認爲XAP文件可能被緩存,而我有些需要防止這種情況。Silverlight 3退出瀏覽器更新

有什麼想法嗎?

回答

5

您需要編寫幾行代碼。

如果您熟悉'單擊'部署,那麼您習慣在Silverlight中不存在的一些選項。你需要自己編寫代碼。

http://nerddawg.blogspot.com/2009/07/silverlight-out-of-browser-apps-how.html

private void Application_Startup(object sender, StartupEventArgs e) 
    { 
     this.RootVisual = new MainPage(); 

     if (Application.Current.IsRunningOutOfBrowser) 
     { 
      Application.Current.CheckAndDownloadUpdateAsync(); 
     } 

,然後在App()構造:

Application.Current.CheckAndDownloadUpdateCompleted += 
    new CheckAndDownloadUpdateCompletedEventHandler(Current_CheckAndDownloadUpdateCompleted); 

和事件處理程序:

void Current_CheckAndDownloadUpdateCompleted(object sender, CheckAndDownloadUpdateCompletedEventArgs e) 
    { 
     // http://nerddawg.blogspot.com/2009/07/silverlight-out-of-browser-apps-how.html 
     if (e.UpdateAvailable) 
     { 
      MessageBox.Show("The application has been updated! Please close and reopen it to load the new version."); 
     } 
     else if (e.Error != null && e.Error is PlatformNotSupportedException) 
     { 
      MessageBox.Show("An application update is available, " + 
       "but it requires a new version of Silverlight. " + 
       "Please contact tech support for further instructions."); 
     } 
    }