7 июня 2008 г. 4:10I´m trying to run SQL Server CE 3.5 on a asp.net enviroment and i´m getting the following error when i try to open a conection: "SqlCeException: Access to the database file is not allowed. [ File name = ]"
All the permissions are set to full control. If a don´t set the right permissions, the error changes to "SqlCeException: Access to the database file is not allowed. [ File name = \dbPath\db.ldf ]"
I´m thinking it is an issue with the temporary file or something like that. The error occurs on the remote host. When a run it debugging on Visual Studio 2008, it works perfectly.
7 июня 2008 г. 10:23МодераторBy default, connection to SQL Compact from ASP.NET are not allowed. To enable this, see this doc: http://msdn.microsoft.com/en-us/library/system.data.sqlserverce.sqlceconnection(VS.85).aspx
7 июня 2008 г. 12:00I saw this topic. It says it is not optimized for asp.net, but should at least work. I have already changed the behaviour of of asp.net compliance by caling "AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);".
7 июня 2008 г. 13:20МодераторThen it must be a file access permission issue, you can use a tool like "FileMon" to find out.
8 июня 2008 г. 0:47i also think that it is a permission issue. I had set full control permission to the asp.net user for all dlls (bin folder) and to the sdf data file. This is how i got this error, without the permissions it would say which file couldn´t access or dll couldn´t load. That´s why i think it has something to do with the temporary file it uses. I tried to put it my connectionstring but still got the error. My guess is that the proccess is triyng to create a temporary file without any specified name.
11 июня 2008 г. 15:49Hey, I'm having the same problem but with a Windows application... I test the application from VS and it works fine, then I create the setup project and install it on my development workstation, all the files are installed as they should, but when I try to open the application I get the "Access to the database file is not allowed.[File name....]".For some reason permissions are not set correctly, after I go to where the .SDF database is and add Write permissions for users it works.So all I'm trying to figure out is how to make it set the proper permissions when the file is installed on the target machine.... I guess having to go and modify permissions after setup on more than 2 computers would be a pain.
2 июля 2008 г. 14:41
Could you use the file security API in windows. Is it fine for your deployment scenario? More info is at http://msdn.microsoft.com/en-us/library/aa446639(VS.85).aspx.
3 июля 2008 г. 2:45
Thanks a lot, I figured out barely yesterday... what I did was that i created another program that runs when the application is installed, this small program sets all the permissions that i need using exactly what you mentioned; both System.Security.AccessControl and System.Security.Principal to identify the well known users' SID, create the new rule and set it on the file, something like:
SecurityIdentifier sid = new SecurityIdentifier( WellKnownSidType.BuiltinUsersSid , null );
FileSecurity dbSec = File.GetAccessControl( dbFile );
dbSec.AddAccessRule( new FileSystemAccessRule( sid , FileSystemRights.Write, AccessControlType.Allow ) );
File.SetAccessControl( dbFile , dbSec );
And taking into account permissions' exceptions this might throw, trying the installer it worked perfectly.
So thanks for your reply!
15 июля 2008 г. 12:44Thanks for your post Caeb. We were running into the same issue. Strange thing is, only one of our 6 machines have this issue. The others run just fine. It turns out that Vista's User Access Control is the culprit. When that is turned off, everything works fine "out of the box". So I'll try implementing your code.
13 марта 2012 г. 16:56
where in your solution do you stick this:
SecurityIdentifiersid = newSecurityIdentifier( WellKnownSidType.BuiltinUsersSid , null);
FileSecuritydbSec = File.GetAccessControl( dbFile );
dbSec.AddAccessRule( newFileSystemAccessRule( sid , FileSystemRights.Write, AccessControlType.Allow ) );
File.SetAccessControl( dbFile , dbSec );