我们有一个ClickOnce WPF应用程序。它会在启动之前检查是否存在其他较新版本,但当然如果用户跳过它,则不会再次询问 - 所以我们在应用程序上有一个按钮来检查更新。如果存在,它将安装它,关闭应用程序并再次重新打开它。问题是当它重新打开时它不再是网络部署!!以下是使用的代码
Private Sub Updates_CheckForUpdates(sender As Object, e As RoutedEventArgs)
Try
Dim vInfo As System.Deployment.Application.UpdateCheckInfo = Nothing
If System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed = True Then
Dim AD As System.Deployment.Application.ApplicationDeployment = System.Deployment.Application.ApplicationDeployment.CurrentDeployment
vInfo = AD.CheckForDetailedUpdate
If vInfo.UpdateAvailable = True Then
Dim vOutput As String = "There is a new update available for HOA Manager!" & Environment.NewLine
vOutput += "Install the update?"
Dim vBox As New AppBoxConfirmation(vOutput)
If vBox.Show = CommonDialog.CustomDialogResults.Yes Then
AD.Update()
AppBoxSuccess("HOA Manager was successfully updated, and will now restart!")
System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location)
'System.Diagnostics.Process.Start(Application.ResourceAssembly.Location)
Application.Current.Shutdown()
End If
Else
'HOA Manager is up to date
AppBoxSuccess("HOA Manager is up to date!")
End If
Else
AppBoxValidation("The application is not network deployed!")
System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location)
'System.Diagnostics.Process.Start(Application.ResourceAssembly.Location)
Application.Current.Shutdown()
End If
Catch ex As Exception
EmailError(ex)
End Try
End Sub
以下代码会检查应用程序上显示的版本号 - 因为' debug'显示我们知道它不是网络部署
Public Function ReturnCurrentVersion() As String
Dim vBuild As String = "Debug"
If System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed Then
Dim vVersion As Version = System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion
Dim vAssembly As Assembly = Assembly.GetExecutingAssembly()
Dim vAssemblyName As AssemblyName = vAssembly.GetName()
vBuild = vVersion.ToString
End If
Return vBuild
End Function
有什么建议吗?
由于
答案 0 :(得分:0)
肯定不知道,直到两次更新后它已经出现在野外,但这可能是答案......
Dim EntryPoint As String = System.Deployment.Application.ApplicationDeployment.CurrentDeployment.UpdatedApplicationFullName
System.Diagnostics.Process.Start(EntryPoint)