Background
I have a BLL DLL that uses NHibernate. I share the same BLL between a client application and the WCF service (even though the client runs on another machine).
I can successfully use either SqlServerCe or SqlServer driver with the BLL with the client application but can only use the SqlServer driver for the WCF.
If I change the hibernate.cfg.xml to use SQL Server I am able to use the service as required with no exceptions being thrown.
The Error
The exact error from the log4net output is:
2421, 5, DEBUG, NHibernate.Connection.DriverConnectionProvider, (null),Obtaining IDbConnection from Driver
2483, 5, DEBUG, NHibernate.Connection.DriverConnectionProvider, (null),Exception thrown obtaining connection: Exception has been thrown by the target of an invocation.
I also have the following code in my WCF code behind file:
AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);
NOTES
- WCF bin directory contains all required DLL's for NHibernate and SqlServerCe
- Does not matter if System.Data.SqlServerCe.dll is in the GAC
- Does not matter if System.Data.SqlServerCe.dll is added to the web.config file under assemblies
- Operating Systems is Windows Server 2003 R2 SP2
- .NET Framework 3.5SP1 installed
- Visual Studio 2008 installed
- Just incase, I uninstalled anything to do with compact edition but this still did not resolve the issue
The Question
How would you try and determine why NHibernate cannot load the SqlServerCe framework?
What forensic analysis would you perform to try and accurately determine the problem so that you can then find ways of resolving it?
Update 1
Incase it was my code I just created a simple website and am able to successfully use the ORM to insert and retrieve records using a hard-coded path to the SDF database. If I use the same hibernate configuration file for the webservice then exception is generated. This does narrow down the problem to the WCF implementation.