0

I am using Firebird embedded in an Asp.Net Web Site. When I run VS2010 as administrator I can successfully call the database, if I run it as a different user I get this error:

System.IO.IOException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
   at System.Reflection.Emit.ModuleBuilder.SavePEFile(RuntimeModule module, String fileName, Int32 entryPoint, Int32 isExe, Boolean isManifestFile)
   at System.Reflection.Emit.ModuleBuilder.Save(String fileName, Boolean isAssemblyFile, PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine)
   at System.Reflection.Emit.AssemblyBuilder.SaveNoLock(String assemblyFileName, PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine)
   at System.Reflection.Emit.AssemblyBuilder.Save(String assemblyFileName, PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine)
   at System.Reflection.Emit.AssemblyBuilder.Save(String assemblyFileName)
   at FirebirdSql.Data.Client.Native.FbClientFactory.CreateInstance(TypeBuilder tb)
   at FirebirdSql.Data.Client.Native.FbClientFactory.GenerateFbClient(String dllName)
   at FirebirdSql.Data.Client.Native.FbClientFactory.GetFbClient(String dllName)
   at FirebirdSql.Data.Client.Native.FesDatabase..ctor(String dllName, Charset charset)
   at FirebirdSql.Data.FirebirdClient.ClientFactory.CreateDatabase(FbConnectionString options)
   at FirebirdSql.Data.FirebirdClient.FbConnectionInternal.Connect()
   at FirebirdSql.Data.FirebirdClient.FbConnectionPool.Create()
   at FirebirdSql.Data.FirebirdClient.FbConnectionPool.CheckOut()
   at FirebirdSql.Data.FirebirdClient.FbConnection.Open()

I've deployed the service in IIS but I get the same error when calling it. Also, to make it work under the admin account I had to copy fbemdeb.dll in windows/system32.

I've done the same call to the DB from within a console application and it works for all user accounts. I only have this problem with the web service.

Any suggestions? i am using Firebird 2.5

Anca
  • 33
  • 6
  • In IIS, find the app pool for your web site, and set the credentials to a windows account that has permissions to connect to the database. – arao6 Jul 29 '14 at 15:25

1 Answers1

1

Sounds like a permission problem. The user that runs the app pool probably can't save on disk. This is suggested by the stack trace you've sent:

   at System.Reflection.Emit.AssemblyBuilder.Save(String assemblyFileName)

Looks like the Firebird API you're uses some technique to build an assembly in runtime. I would look in the API documentation to see if there's a way to configure any temporary directories or something like that.

Eric Lemes
  • 561
  • 3
  • 10
  • 1
    See https://github.com/cincuranet/NETProvider/blob/master/NETProvider/src/FirebirdSql.Data.FirebirdClient/Client/Native/FbClientFactory.cs for the code. – Mark Rotteveel Jul 29 '14 at 17:51
  • Looks like some magic with AppDomain.CurrentDomain.DefineDynamicAssembly is causing the problem. Can't find resources pointing what are the permissions required. – Eric Lemes Jul 29 '14 at 20:16
  • It looks like it only saves the assembly to disk with a debug build of the library and as just a file name is used, it is probably saved to the working folder of the application. This either means the release version of Firebird.net was incorrectly built as debug, or the OP uses his own build of Firebird.net in debug mode. – Mark Rotteveel Jul 30 '14 at 06:54
  • I've checked the source code for FBClientFactory and indeed it will create an assembly at runtime. It looks that FirebirdSql.Data.FirebirdClient.dll v2.0 was built in debug mode. I've updated to FirebirdSql.Data.FirebirdClient.dll v4.5 and everything works fine, no Access is denied error. This was useful http://ramsees.blogspot.co.uk/2010/10/beware-firebird-embedded-asp.html – Anca Jul 30 '14 at 14:08