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

Getting EsentFileAccessDeniedException from Api.JetInit

Aug 19, 2013 at 10:44 PM

I am new to Esent and am just starting writing my prototype. This library is great. The documentation and samples have helped me put together my working prototype quite quickly.

Now I am adding more functionality and using it from an extended folder menu and I suddenly started getting this EsentFileAccessDeniedException from Api.JetInit. It does not even tell which file it is complaining about. I searched the forum for this exception but there is no mention. I am the only one working on this machine using an Administrator group member account.

Here are first 3 lines of the exception trace:

Microsoft.Isam.Esent.Interop.EsentFileAccessDeniedException: Cannot access file, the file is locked or in use
at Microsoft.Isam.Esent.Interop.Api.Check(Int32 err) in e:\src\codeplex_svn\codeplex\EsentInterop\Api.cs:line 2859
at Microsoft.Isam.Esent.Interop.Api.JetInit(JET_INSTANCE& instance) in e:\src\codeplex_svn\codeplex\EsentInterop\Api.cs:line 130

Please help,

Aug 19, 2013 at 11:17 PM
extended folder menu
You're using a ESENT database from shell extension, aren't you?
There might be several explorer.exe processes, only the first instance of your shell extension runs OK, while subsequent instances get the error because of file sharing violation. Can it be the cause of your problem?
It does not even tell which file it is complaining about
You can find it using free Process Monitor software:
Set the filter so it only display failed file system operations, and reproduce the problem.
Aug 19, 2013 at 11:32 PM
Yes. Shell Extension. That is the right term. Sorry, I am a bit new to Microsoft world.

I got this error the moment I connected the Esent storage option to the shell extension. May be there was a different error first time. I continued testing and have an update. My standalone tests from the studio continue to work just fine on the exact same file. I can overwrite, read, reread without problem. Only gives error when I try to use it from the shell extension. I got the process monitor. Working on it.

Error not completely resolved yet.
Aug 19, 2013 at 11:45 PM
Some more detail on the usage. The Esent db is not being directly used from the shell extension. The shell extension just gives additional menus which launch separate apps which all use the db. So far I am using only a console app from studio and a forms app launched from the shell extension.
Aug 20, 2013 at 12:02 AM
(I have to run soon -- apologies for brevity)

Check out the Application event log for 'ESENT' events. There should be additional details logged there.

Aug 20, 2013 at 3:24 AM
I checked and yes there are a plenty of events logged for that database. Overall message is quite clear that Esent is trying to recover that db file. I am quite confused as to why. I am certain that at least when I run my standalone test, the db is being properly started and shutdown. There is hardly any significant amount of data. I will keep an eye on the events log as I test more. If I reach any definite conclusions I will post them.

Aug 20, 2013 at 2:50 PM
This problem was resolved by setting the Instance Parameters. In my hurry to see things working, I had let all the instance parameters go to default. Didn't see any harm in it. Thought it better than setting them wrong. Now I set them and the problem is gone. I think it must have been the log, recovery and or other directories that must have made the difference. Not certain exactly which one. Didn't expect such confusing exception for not setting though.