2012-06-01 16 views
1

無法從NHibernate.Driver.SqlServerCeDriver, NHibernate, Version=3.3.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4創建驅動程序。使用流利的NHibernate SQL Server CE無法創建驅動程序

內exeption: 在裝配System.Data.SqlServerCe的IDbCommand和執行的IDbConnection找不到。確保程序集System.Data.SqlServerCe位於應用程序目錄或全局程序集緩存中。如果程序集位於GAC中,請使用應用程序配置文件中的元素指定程序集的全名。

這是我在嘗試使用流利的nHibernate時得到的錯誤!

我嘗試通過配置的簡單示例不能很好地與本地數據庫 使用此dll。

我的代碼:

private static String ConnectionString = "Data Source = Database1.sdf"; 

public static ISessionFactory CreateSessionFactory() 
{ 
     return Fluently.Configure() 
      .Database(MsSqlCeConfiguration.Standard 
      .ConnectionString(ConnectionString) 
      .Driver<NHibernate.Driver.SqlServerCeDriver>() 
      .Dialect<NHibernate.Dialect.MsSqlCeDialect>()) 
      .Mappings(m => m.FluentMappings.AddFromAssembly(System.Reflection.Assembly.GetExecutingAssembly())) 
      .ExposeConfiguration(BuildSchema) 
      .ExposeConfiguration(x => x.SetProperty("connection.release_mode", "on_close")) 
      .BuildSessionFactory(); 
} 

private static void BuildSchema(Configuration configuration) 
{ 
     SchemaExport schemaExport = new SchemaExport(configuration); 
     schemaExport.Execute(false, true, false); 
} 

謝謝!這很重要!

我發現它打破了buildsessionfactory ... helpppp !!!!

回答

2

你確定你的bin目錄中有NHibernate版本= 3.3.0.4000嗎?看起來你的bin目錄中有不同的NHibernate版本。

如果你確信它的存在,檢查你的引用是否正確:

你有沒有在你的項目的引用:

"System.Data.SqlServerCe" 

這是位於以下目錄:

"C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Desktop\System.Data.SqlServerCe.dll" 

請確保您有:

"Copy Local" to true. 
+0

是的,我可以肯定它可能是別的東西嗎?也許東西與組件文件? – user1430430

+0

我加這個exeption的內部豁免..也許它可以幫助 – user1430430

+0

沒關係,我發現它!!!! thanku非常愉快的一天! – user1430430

相關問題