Saturday, October 23, 2010

BEWARE FIREBIRD EMBEDDED/ ASP.NET DEVELOPERS

I was struggling with this problem in one of my ASP.NET pages, it was going to be the first time I use Firebird Embedded with ASP.NET. In the development machine everything were find but in the production machine I had an "Access denied" exception, so I changed from Firebird Embedded to Firebird server and everything worked fine, but I had this new problem, some of our customers use Firebird 2.1 and my web page needs Firebird 2.5, so I had to find a solution for my FB Embedded problem, What I did was to give privileges to the IIS user to the c:\windows\System32 folder and everything worked.
So part of the problem was solved, but giving privileges to system32 was not righ and unconfortable, it helped in the first couple of deployments but I wasn't happy at all with the solution, I was even thinking in use SQLite for the job but I know FB so well and I must say is pretty awesome so I had to solve the problem.

After looking a litle deeper I find the root of the problem, my Firebird.Data.FirebirdClient.dll was compiled in Debug mode and in this mode it creates a file named DynamicAssembly.dll, the code is in FbClientFactory.cs line 229, the code looks like this:

#if (DEBUG)
Assembly ab = (AssemblyBuilder) tb.Assembly;
ab.Save("DynamicAssembly.dll");
#endif

So the solution was easy, I recompiled Firebird.Data.FirebirdClient.dll in release mode and everything was solved. Im now a pretty happy man.

So you wonder why I compile the library my self? That's becuase I made some modifications to the constructors, that's the wonderful thing of OpenSource and FB in special, you just have to download the source and recompile it.

I hope this helps to anyone using FB Embedded with ASP.NET.