question

MikeYeager-2259 avatar image
0 Votes"
MikeYeager-2259 asked MikeYeager-2259 commented

ClickOnce Applications Fail to Update

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://docs.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-generaldotnet-csharpwindows-wpf
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JackJJun-MSFT avatar image
0 Votes"
JackJJun-MSFT answered MikeYeager-2259 commented

@MikeYeager-2259, 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.





· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you for the reply. We have considered wiping out the cache programmatically, but would rather find a solution vs. a work-around. I believe wiping out the cache requires admin rights, which we don't want to grant. It also wipes out ALL click once (and other) applications requiring them all to be downloaded. Finally, when the issue occurs, the app won't start at all, meaning we'd have to create another app to wipe out the cache. Currently, we use a batch file to do this.

It's incredible to me that this is suddenly so very broken and there appears to be no support or any way to troubleshoot. I can't even tell f the issue is in Visual Studio, Windows, .NET... Microsoft just brought ClickOnce into .NET 5 last year. At this point I'm wondering if it wouldn't be better to go back to InstallShield or some other 3rd party. Have done some MSIX, but I'm worried it will end up as flaky as ClickOnce has suddenly become.

0 Votes 0 ·

@MikeYeager-2259, currently I could not find a better way to replace the above solution. Maybe you could report the problem about .NET in Developer Community




0 Votes 0 ·

Thanks for the feedback. I'll do that.

0 Votes 0 ·