ClickOnce Applications Fail to Update

Mike Yeager 26 Reputation points
2021-09-16T19:09:59.76+00:00

We have a .NET 4.8 WPF application deployed to a couple hundred desktops using ClickOnce published from Visual Studio 2019. Mot of the desktops are Windows 10. A very large percentage of the time the update fails. We found this article that describes it perfectly and the work-around works.

https://learn.microsoft.com/en-us/troubleshoot/dotnet/framework/clickonce-application-fails-update

Problem is this happens ALL THE TIME. Lately, we've been doing an update every day. We can find no rhyme or reason to it. Having our users in various offices deleting their app cache is crazy! It's become untenable. We've used ClickOnce with many clients over the years and never had this occur. Now it happens every day. Can't find any way to troubleshoot it.

Thanks in advance!
Mike

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,606 questions
Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,670 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,233 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jack J Jun 24,286 Reputation points Microsoft Vendor
    2021-09-17T07:22:28.753+00:00

    @Mike Yeager , If you don't want to delete the app cache manually, I recommend that you could write the code to delete the files in advance.

    Code:

      if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)  
                {  
                    string path = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\" + "AppData\\Local\\Apps\\2.0";//Get file cache path  
                    MessageBox.Show(path);               //check if path is correct  
                    System.IO.DirectoryInfo di = new DirectoryInfo(path);  
                    foreach (FileInfo file in di.GetFiles())  
                    {  
                        file.Delete();                    //delete all files  
                    }  
                    foreach (DirectoryInfo dir in di.GetDirectories())  
                    {  
                        dir.Delete(true);                //delete all folders  
                    }  
      
                }  
    

    You could put the above code in the Window_Load event.


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.