We ran into a problem with our application deployed with clickonce. If we create files in ApplicationDeployment.DataDirectory that exceed the known Windows 260 character limit, then at the time an application update is deployed, the application will crash. We get this in the windows event log:
Application: fubar.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Runtime.InteropServices.COMException
at System.Deployment.Internal.Isolation.IActContext.SetApplicationRunningState(UInt32, UInt32, UInt32 ByRef)
at System.ActivationContext.SetApplicationState(ApplicationState)
at System.AppDomain.SetupDomainForApplication(System.ActivationContext, System.String[])
at System.AppDomain.SetupApplicationHelper(System.Security.Policy.Evidence, System.Security.Policy.Evidence, System.ApplicationIdentity, System.ActivationContext, System.String[])
at System.AppDomain.InitializeDomainSecurity(System.Security.Policy.Evidence, System.Security.Policy.Evidence, Boolean, IntPtr, Boolean)
It only occurs if there are files in the data directory that exceed the 260 character limit. Without the files, the upgrade works ok. In general, our application is working ok with long path names, it is just an issue with click once.
I'm a bit stuck on where to go from here. Is there any configuration or settings in windows, .Net or clickonce that ought to help with this? We've tried the usual options and none of them seemed to make a difference:
https://blogs.msdn.microsoft.com/jeremykuhne/2016/07/30/net-4-6-2-and-long-paths-on-windows-10/ https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#enable-long-paths-in-windows-10-version-1607-and-later
It just seems to be a bug in clickonce at this point. My best bet at this time seems to be to migrate our filesystem access to use IsolatedStorage, but that seems like a big investment in time. I'm hoping that someone will know some simple thing to try.