Solved

Click once application update VB .net

Posted on 2013-12-03
1
1,065 Views
Last Modified: 2014-01-20
Hi,

I want to make my application update automatically and i tried from
Publish > Updates
and checked on (the application should check for updates) and tried the both (after the application starts) and (before the application starts) and in the both ways it didn't work and no update message appears.

so i tried to do it programmatically using the following sub and it worked:

but when i checked on (specify a minimum required version for this application)
it gives me error (user has refused to grant required permissions to the application)

and when i did not checked it i works but update the application every time i open it and roll the update back when the application being closed and update it again when opening.


so is there any way to make my desktop application update automatically?

I am using VS2012 with a desktop application.

Private Sub InstallUpdateSyncWithInfo()
        Dim info As UpdateCheckInfo = Nothing

        If (ApplicationDeployment.IsNetworkDeployed) Then
            Dim AD As ApplicationDeployment = ApplicationDeployment.CurrentDeployment

            Try
                info = AD.CheckForDetailedUpdate()
            Catch dde As DeploymentDownloadException
                MessageBox.Show("The new version of the application cannot be downloaded at this time. " + ControlChars.Lf & ControlChars.Lf & "Please check your network connection, or try again later. Error: " + dde.Message)
                Return
            Catch ioe As InvalidOperationException
                MessageBox.Show("This application cannot be updated. It is likely not a ClickOnce application. Error: " & ioe.Message)
                Return
            End Try

            If (info.UpdateAvailable) Then
                Dim doUpdate As Boolean = True

                If (Not info.IsUpdateRequired) Then
                    Dim dr As DialogResult = MessageBox.Show("An update is available. Would you like to update the application now?", "Update Available", MessageBoxButtons.OKCancel)
                    If (Not System.Windows.Forms.DialogResult.OK = dr) Then
                        doUpdate = False
                    End If
                Else
                    ' Display a message that the app MUST reboot. Display the minimum required version.
                    MessageBox.Show("This application has detected a mandatory update from your current " & _
                        "version to version " & info.MinimumRequiredVersion.ToString() & _
                        ". The application will now install the update and restart.", _
                        "Update Available", MessageBoxButtons.OK, _
                        MessageBoxIcon.Information)
                End If

                If (doUpdate) Then
                    Try
                        AD.Update()
                        MessageBox.Show("The application has been upgraded, and will now restart.")
                        Application.Restart()
                    Catch dde As DeploymentDownloadException
                        MessageBox.Show("Cannot install the latest version of the application. " & ControlChars.Lf & ControlChars.Lf & "Please check your network connection, or try again later.")
                        Return
                    End Try
                End If
            End If
        End If
End Sub
0
Comment
Question by:ayran1805
1 Comment
 
LVL 12

Accepted Solution

by:
ktaczala earned 500 total points
ID: 39694537
Are you installing this app for internal use or for public use?

If Internal use, specify installation folder as a shared folder (for example a share on a server that everyone has access to).
Then Specify "this application should check for updates", and "minimum version"( if you want to force the update), if you don't specify minimum update then user can ignore the update and continue to use to older version.
The update location should point to the same shared folder.

The deploy folder doesn't matter, once you compile your app copy the folder specified in your deploy location to the shared folder.  Once the user installs from there all you need to do is copy the next version into the same share and it will update next time they open or close your app. depending on what you selected.

If external then point the installation folder and the update folder to the web site, but you need to make sure you can write to the web site.

I have mine setup so my installation folder is "ftp://www.mywebdomain.com/myapp" and my update folder is "http://www.mywebdomain.com/myapp/myapp.htm"  when I publish it prompts me for my login info for the ftp access.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

805 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question