2012-06-01 43 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

相关问题