I have a .NEt 3.5 C# program written using VS2008 that uses a SQL Server CE database. I also have an installer for the program which I have created using the Visual Studio setup project type.
Within the program designer, the database file is included as type "content".
Within the installer program, the output for "content files" is the application folder.
This works fine on XP, but under Vista an error occurs when attempting to run the program. The error is that the program does not have permission to access the database file.
How do I fix this? Is there "proper" way to set this up in the installer project? Or do I need to write additional code in the application project? Do I need two different installer projects, one for XP and one for Vista? (Or 3, one for XP and one each for 32 and 64 bit Vista...).
And what about Windows 7, is that different again?
I am finding this very frustrating, as I only have an XP machine on which to develop and test.
T.I.A.
Loading

Kirtan PatelRank #292 · 8.6K reputationPosted Feb 26, 2010, 8:15 PM EST
hope it can solve your problem .
Don21 reputationPosted Feb 26, 2010, 9:00 PM EST
Kirtan PatelRank #292 · 8.6K reputationPosted Feb 26, 2010, 11:33 PM EST
Don21 reputationPosted Feb 27, 2010, 8:37 AM EST
Sam HobbsRank #107 · 20.5K reputationPosted Feb 27, 2010, 2:46 PM EST
Perhaps you need to get a book about software security; there are not many but there is at least one. Don't try to ignore security and just use Administrator rights to bypass the issure.
Don21 reputationPosted Feb 27, 2010, 6:35 PM EST
Sam HobbsRank #107 · 20.5K reputationPosted Feb 28, 2010, 6:36 AM EST
Also see Special Folders and Custom Folders and Environment.SpecialFolder Enumeration. Also Inside Windows 7:Introducing Libraries appears relevant.
Don21 reputationPosted Feb 28, 2010, 3:23 PM EST
I tried the following changes:
In the application, I load the datacontext from the common applicaton data folder instead of the porgram files folder:
db = new FDDB.FDDB(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\" + Application.ProductName + "\\FDDB.sdf")
In the setup project I created a custom folder on the target machine with the following properties:
DefaultLocation = [CommonAppDataFolder]\[ProductName]
Property = COMMONAPPDATAFOLDER
I then attempted to run my program on my XP machine with a user who is only a member of the "users" group.
The application fails when database access is attempted. The error is "access to the database is not allowed".
So the only folder that seems even remotely "correct" according to the microsoft documentation still doesn't work. Is anyone able to provide a concrete answer to this other than telling me to refer to documentation that doesn't exist?
Don21 reputationPosted Feb 28, 2010, 5:31 PM EST