| DotNetFirebird Using Firebird SQL in .NET. |
|
Home
Features
Download
Documentation
FAQ
Tools and Code
About
Blog
|
Monday, November 14, 2005
How to Use Embedded Firebird in ASP.NET ApplicationsI receive many e-mails asking how to use embedded Firebird with ASP.NET applications. This looks very appealing, especially for the hosted websites - imagine just copying your database engine together with your application to the server.... But unfortunately, it is not so easy: Problem #1 - How to find fbembed.dll The fbembed.dll is not a managed assembly, it's a classical DLL called using PInvoke (DllImport attribute). By default, the Firebird ADO.NET Provider is looking for the fbembed.dll in the default paths, which includes the system directory (e.g. C:\Windows\System32) but not the ASP.NET application bin directory. This is a problem when you don't have the access to the system directory - this is something that your hosting provider rarely allows you to. The solution is to use the "clientlibrary" parameter in connection string and specify path to fbembed.dll. Problem #2 - Overlapped Worker Process Recycling on IIS6 ASP.NET uses a feature that help against poorly written ASP.NET application to block the entire server - it recycles the ASP.NET working process both regularly. By default, IIS6 uses overlapped recycling where there is a new process started before the old is stopped to ensure uninterrupted operation. The problem is that the fbembed.dll exclusively locks the database for the owner process so if you run another process simultaneously the database won't be accessible before the first process stops. You might want to accept this but it really is not an optimal solution. The solution is to turn off the overlapped recycle (by setting the DisallowOverlappingRotation metabase property to true). However, this might cause outages of your application during recycle. Conclusion Don't do that ;-). Really, fbembed.dll was not built to handle such use. You can make it work but it is just a hack. Comments:
POP! There goes my bubble.
Thanks for the tips and workarounds for using Embedded Firebird in an ASP.NET application even if you don't recommend it. Using LoadLibrary from Kernel32.dll seemed to work during one of my previous experiments, but it's not working now that my hosting provider has gone live with .NET 2.0 (it does not return a handle when loaded). It still works on my development system though (maybe I'm just not doing something right on my hosted site).
If two ASP.NET web sites using Firebird.Net (with embedded Firebird) is sharing the same application pool in IIS 6.0, the second web site will fail with the following error the first time it tries to access its database:
[FbException: No message for error code 335544373 found.] FirebirdSql.Data.Firebird.FbConnectionInternal.Connect() +321 FirebirdSql.Data.Firebird.FbConnectionPool.Create() +49 FirebirdSql.Data.Firebird.FbConnectionPool.CheckOut() +202 FirebirdSql.Data.Firebird.FbConnection.Open() +370 Note that the web sites are using entirely separate folders and data files (and connection strings). It seems that Firebird.Net can only be used in one AppDomain per process... Any comments / workarounds? Thanks, Ole
That is really disappointing. I was hoping that this would be the Hypersonic equivalent for .NET
Sigh!
So can you tell me how to hack your code, then I can use your data provider in my asp.net application???
Thanks!
Thanks for your comments.
Problem 1 no problem to modify the path. Problem 2 : you don't recomand to change recycling process. ok. But now : can we use this embeded db or is better to choose an other database ? Blog comments are closed.
Previous
Archives
Copyright © 2005 - 2007 DotNetFirebird |