Solved

Click once application update VB .net

Posted on 2013-12-03
1
1,058 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
asp.net mvc input file 2 32
C# Offline Apllication 5 51
Not showing JavaScript in the list 5 35
Javascript and Jquery not firing 9 37
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

932 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now