Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on an application having ClickOnce Deployment implemented. When I am going to check the availability of newer version programmatic-ally (using C#) it gives me exception like Application not installed?

One more point - while debugging the value of ApplicationDeplyment.IsNetworkDeployed always remains false - not sure why??

Please suggest any way to handle this.
Posted

1 solution

You are getting exception that application not installed because it will going to check that application is installed on local machine or not ... if not installed then it might get you issue.

And for resolving issue related to ApplicationDeployment.IsNetworkDeployed remains false because in your publish status you might not deployed on network location or applied network location might not be available from application installed machine.


I had also came with same problem and there is no way to debug it .. so what you might do is you can deploy this application somewhere in your network (Make Network location FTP directory) and now try to access it from local machine and Install application Instance and then you Might check your functionality.There is no other way and what best probably you can do for checking control flow and values at different stage you can use logging of activity into some file and then get the exact idea of implementation and also got the error if any occurs during that updation (Other alternative is that you can popup a Messagebox with values during updation stage)


Please Try to avoid use of any application window usage on application startup as it might cause a problem for you ..



http://msdn.microsoft.com/en-us/library/ms228671(v=vs.80).ASPX[^]



Please find my Working code as below.Which is running fine actually and i had copied this code from MSDN but currently dont know exact link(Below Code Sample is for WPF Application).



C#
protected override void OnStartup(StartupEventArgs e)
        {
            Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
            InstallUpdateSyncWithInfo();
            base.OnStartup(e);
        }





  private void InstallUpdateSyncWithInfo()
        {
            UpdateCheckInfo info = null;
            
            if (ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
                try
                {
                    //here as parameter we had provided false
                    //because every time starts up application it will check for updates
                    //and will not store the previous check result into memory.
                    info = ad.CheckForDetailedUpdate(false);
                }
                catch (DeploymentDownloadException dde)
                {
                    MessageBox.Show("The new version of the application cannot be downloaded at this time. \n\nPlease check your network connection, or try again later. Error: " + dde.Message);
                    return;
                }
                catch (InvalidDeploymentException ide)
                {
                    MessageBox.Show("Cannot check for a new version of the application. The ClickOnce deployment is corrupt. Please redeploy the application and try again. Error: " + ide.Message);
                    return;
                }
                catch (InvalidOperationException ioe)
                {
                    MessageBox.Show("This application cannot be updated. It is likely not a ClickOnce application. Error: " + ioe.Message);
                    return;
                }

                if (info.UpdateAvailable)
                {
                    Boolean doUpdate = true;

                    if (!info.IsUpdateRequired)
                    {
                        MessageBoxResult dr = MessageBox.Show("An update is available. Would you like to update the application now?", "EasyLink - Update Available", MessageBoxButton.OKCancel);
                        if (!(MessageBoxResult.OK == dr))
                        {
                            doUpdate = false;
                        }
                    }
                    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", MessageBoxButton.OK,
                            MessageBoxImage.Information);
                    }

                    if (doUpdate)
                    {
                        try
                        {
                            MessageBox.Show("The application will update in background. Please click on OK and wait for a moment...", "Background Update");
                            ad.Update();
                            MessageBox.Show("The application has been upgraded to the Newer Version (v" + ad.UpdatedVersion.ToString() + "). Please restart the application to run the New Version.", "Update Successful");
                            Application.Current.Shutdown();
                        }
                        catch (DeploymentDownloadException dde)
                        {
                            MessageBox.Show("Cannot install the latest version of the application. \n\nPlease check your network connection, or try again later. Error: " + dde);
                            return;
                        }
                    }
                }
}
        }
 
Share this answer
 
v3
Comments
Adwaitam 19-Jun-14 17:59pm    
Thanks Ashok...I will give a try on this tomorrow since working on some other problem as of now. But I do remember the link from MSDN for your solution -

http://msdn.microsoft.com/en-us/library/ms404263.aspx[^

Thanks for your reply.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900