2010-11-29 27 views
6

我试着用我的第一个项目与流利NHibernate(任何NHibernate的味道)。我已经无法让过去创造的,我下面的异常运行在会话工厂对象的点:流利NHibernate未能创建会话工厂与SQLCE

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: 

我使用的是最新的FluentNHibernate二进制文件。 VS 2010,在Window 7 x64上。我已经将System.Data.SqlServerCe程序集设置为“Copy Local”,将项目的目标平台更改为x86。

流利的配置是:

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; 

注:engine.CreateDatabase()工作正常。

任何帮助/想法请吗?

回答

7

好吧,算出来。

复制本地并不适用于我正在使用的测试项目,因此,这些库没有被复制到测试项目的bin文件夹中。添加所有的库作为测试项目的参考,并设置复制本地,以使其工作。

+0

顺便说一句,我不需要将项目定位到x86。我能够让代码运行正常,目标是“任何CPU” – Sameera 2010-11-30 11:22:32