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()工作正常。
任何幫助/想法請嗎?
順便說一句,我不需要將項目定位到x86。我能夠讓代碼運行正常,目標是「任何CPU」 – Sameera 2010-11-30 11:22:32