I am creating a new version of an existing Windows desktop application that has been working well for several years. The application uses a SqlServerCe database, which is installed to the DataDirectory of the machine. The new version of the application is being created to be compatible with 64-bit machines. I have migrated the code to a Parallels VM running Windows 10 on my Macbook, and I am building the new version using Visual Studio 2017. The build works fine (I am using a Setup Wizard project to create the Installation files). But, when I install the application, I get an error on the first attempt to access the database.
The error is: Access to the database file is not allowed. [ 1884,File name = C:\ProgramData\CompanyName\ApplicationName\AppDataBase.sdf,SeCreateFile ].
The .sdf is not marked as read only. If I go to the .sdf file, once it is installed, and give read, write, and modify permissions to Everyone (using the file explorer), then the application can access the file and there is no error. However if I try to do this from within my code using File.SetAccessControl, I get the access error again. I don't see any way to set permissions on the .sdf file during the installation process, using the Setup Wizard functionality (file system view).
Here is the connection string I am using:
<connectionStrings>
<add name="ApplicationName.Properties.Settings.ApplicationNameConnectionString"
connectionString="Data Source=|DataDirectory|AppDataBase.sdf"
providerName="Microsoft.SqlServerCe.Client.4.0" />
</connectionStrings>
This worked fine when building using Visual Studio 2010 and deploying on x86 machines. Thank you, in advance, for any advice you can give.