tags:

views:

941

answers:

1

I have a WinForms app that I deploy using ClickOnce. In the application project I have some files marked as Content which is also marked as "Data File" in the Application Files dialog in the Publish settings. I have also some content files that are marked as "Include Auto".

When I publish, install the application and then execute it crashes immediately on startup with a DirectoryNotFoundException (full stacktrace below).

Looking into the application folder I can find all files that was marked "Include Auto", neatly placed along with the executables. The files marked as "Data File" though is not installed (I have checked both the executable folders and the Data folder).

Note that publish and install is both done from a folder on my local machine, not via a website.

If I change from "Data File" to standard include on all content files, everything works as a charm.

I'm running (gasp) Windows XP SP3 and .Net 3.5 SP1.

System.IO.DirectoryNotFoundException was unhandled Message="The system cannot find the path specified. (Exception from HRESULT: 0x80070003)" Source="mscorlib" StackTrace: at System.Deployment.Internal.Isolation.IActContext.SetApplicationRunningState(UInt32 dwFlags, UInt32 ulState, UInt32& ulDisposition) at System.ActivationContext.SetApplicationState(ApplicationState s) at System.AppDomain.SetupDomainForApplication(ActivationContext activationContext, String[] activationData) at System.AppDomain.SetupApplicationHelper(Evidence providedSecurityInfo, Evidence creatorsSecurityInfo, ApplicationIdentity appIdentity, ActivationContext activationContext, String[] activationData) at System.AppDomain.SetDomainManager(Evidence providedSecurityInfo, Evidence creatorsSecurityInfo, IntPtr parentSecurityDescriptor, Boolean publishAppDomain) at System.AppDomain.SetDefaultDomainManager(String fullName, String[] manifestPaths, String[] activationData) InnerException:

+1  A: 

After some more trial and error I found that the DirectoryNotFound exception occurs when my data files are located in subfolders of a subfolder. If data files are located in the project root or in a first level subfolder everything works as expected.

The problem seems also to be related to the fact that in some of these subfolders I had some files marked as Include and some as Data. This probably causes some confusion during deployment in which the data files doesn't get deployed.

Finally, what I had to do to get things the way I wanted was to uninstall any previous version of the app. Next, organizing my data files in the project like this:

\Testfiles\Filegroup1\data1.txt
\Testfiles\Filegroup1\data2.txt
\Testfiles\Filegroup2\moredata1.txt
\Testfiles\Filegroup2\moredata2.txt

Then I mark all files within each folder as Data. Now everything gets deployed nice and dandy and the loader doesn't crash at startup.

Peter Lillevold