6

I'm trying out my very first project with Fluent NHibernate (any NHibernate flavor for that matter). I've been unable to get past the point of creating a Session Factory object as I'm running in to the following exception:

InnerException: NHibernate.HibernateException
                      Message=The IDbCommand and IDbConnection implementation in the assembly System.Data.SqlServerCe could not be found. Ensure that the assembly System.Data.SqlServerCe is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use <qualifyAssembly/> element in the application configuration file to specify the full name of the assembly.
                      Source=NHibernate
                      StackTrace:
                           at NHibernate.Driver.ReflectionBasedDriver..ctor(String driverAssemblyName, String connectionTypeName, String commandTypeName)
                           at NHibernate.Driver.SqlServerCeDriver..ctor()
                      InnerException: 

I'm using the latest FluentNHibernate binaries. VS 2010, on Window 7 x64. I've set the System.Data.SqlServerCe assembly to "Copy Local" changed the project's target platform to x86.

The fluent config is:

var config  = Fluently.Configure()
                        .Database(MsSqlCeConfiguration.Standard.ShowSql().ConnectionString(cnxString))
                        .Mappings(m => m.FluentMappings.AddFromAssemblyOf<SyncContract>());

if (!File.Exists(dbPath))
{
     var engine = new System.Data.SqlServerCe.SqlCeEngine(cnxString);
     engine.CreateDatabase();

     config.ExposeConfiguration(c => new SchemaExport(c).Create(false, true));
}
return config;

Note: engine.CreateDatabase() works fine.

Any help/ideas please?

1 Answer 1

7

Ok, figured it out.

Copy Local didn't apply to the test project I was using and consequently, the libs didn't get copied to the bin folder of the test project. Added all the libraries as references to the test project and set copy local on them to get this to work.

2
  • BTW, I didn't need to target the project to x86. I was able to get the code to run fine targetted to "Any CPU"
    – Sameera
    Nov 30, 2010 at 11:22
  • 1
    I ran through the same issue. "Copy Local" was inoperative for tests running on TFS. I had to add all the corrects libs using test settings.
    – mathieu
    Feb 28, 2012 at 18:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.