This project has moved and is read-only. For the latest updates, please go here.

ESENT database engine file access denied

Jul 29, 2010 at 12:15 AM

I am trying to using the ESENT windows database with the managedesent library but I always get the error

Error FileAccessDenied (JET_errFileAccessDenied, Cannot access file, the file is locked or in use)


The code to open the database is

private static IDictionary<string, PropertyStruct
> m_Dictionary = new PersistentDictionary<string, PropertyStruct>("CachedPropertySummary2");


I am testing this on Windows 7 and the application is an ASP.NET application. 


Jul 29, 2010 at 12:31 AM

Is it possible that you have more than one application accessing the same file? Like two IIS applications or two Visual Studio web servers running? Or that you have already instantiated an instance of PersistantDictionary pointing to the same file?

Jul 29, 2010 at 1:35 AM

That is what I first thought but it shouldn't be the case, there is only one application using this. You can see I put a 2 after the name to make sure it was a not locked by some previous instance but the first time I run it the same error occurs. I am testing it using the Visual Student Development Server (Cassini) rather than IIS so I am not sure if that is a problem. The sample app runs fine so I will try and look at it more tonight.

Jul 29, 2010 at 1:42 AM

If you only have one PersistentDictionary object (creating a second will fail like that) then my guess is that you don't have permissions to write to the current (default) directory. Set the full path to the directory instead (e.g. @"c:\temp\CachedPropertySummary").


Jul 29, 2010 at 6:53 AM

Yes, of course. With only the filename, and not the full path, you try to write to the /bin folder. That is not allowed, nor is it something we usually want to do.