Solved

Click once application update VB .net

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 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

12 Experts available now in Live!

Get 1:1 Help Now