?
Solved

Click once application update VB .net

Posted on 2013-12-03
1
Medium Priority
?
1,112 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 12

Accepted Solution

by:
ktaczala earned 2000 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

Stack Overflow Podcast - Developer Story

Welcome to the Stack Overflow podcast recorded Thursday July 20 at Stack Overflow Headquearters in NYC. Your hosts today are podcast regulars Jay Hanlon, David Fullerton, and Ilana Yitzhaki, plus the quite irregular Matt Sherman (Stack Overflow Engineering Manager extraordinaire)

Question has a verified solution.

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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

765 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