Pergunta

We have a ClickOnce WPF application. It checks if another newer version exists before starting, but of course if the user skips it they don't get asked again - sooo we have a button on the app to check for updates. If one exists it will install it, close the app and reopen it again. The problem is when it reopens it is no longer network deployed!! Below is the code used

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

The code below checks the version number for display on the app - since 'debug' displays we know that it's not network deployed

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

Any suggestions?

Thanks

Foi útil?

Solução

Won't know for sure until this has been out in the wild after two updates, but this COULD be the answer...

Dim EntryPoint As String = System.Deployment.Application.ApplicationDeployment.CurrentDeployment.UpdatedApplicationFullName
                    System.Diagnostics.Process.Start(EntryPoint)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top