views:

39

answers:

2

I am working on a SQL Compact demo app, and one of the things I my setup project does is copy an SDF file to the user's c:\ProgramData folder. However, when the app is run on the user's machine, I get the following error:

System.Data.EntityException: The underlying provider failed on Open. ---> System.Data.SqlServerCeException: Access to the database file is not allowed. [File name = c:\ProgramData\Foresight Systems\SQL Compact Demo\LocalData.sdf]

I am puzzled as to what's causing this error. Isn't c:\ProgramData the preferred location for this sort of file? What do I need to do in my setup project to get this to work? Thanks for your help.

A: 

A few things to check perhaps(?):

  • the .sdf has a file attribute of readonly
  • is the application being run as administrator or UAC access being granted?
p.campbell
No readonly attribute. Does my app need elevated privileges to write to c:\ProgramData? It writes Log4Net entries to a subfolder there without problem.
David Veeneman
A: 

I accepted p.campbell's answer, because he identified the security issue. I went back and took a look at the Security tab for the c:\ProgramData folder, and I discovered that the Users group only has read permissions for this folder. So, It's probably not the best place to put my SDF file. I'll post a separate question regarding where to put the file.

David Veeneman
@David: interesting find. Will be interested to see the other question.
p.campbell