当前位置: 动力学知识库 > 问答 > 编程问答 >

Using Fluent NHibernate SQL Server CE cannot create the driver

问题描述:

Could not create the driver from NHibernate.Driver.SqlServerCeDriver,

NHibernate, Version=3.3.0.4000, Culture=neutral,

PublicKeyToken=aa95f207798dfdb4.

inner exeption:

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 element in the application configuration file to specify the full name of the assembly.

This is the error I get when I try to use fluent nHibernate!

I try the simple examples by the configuration doesn't work well with local database

using this dlls.

My code:

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);

}

Thank you! It's very important!

i found that it break in the buildsessionfactory...helpppp!!!!

网友答案:

Are you sure you do have Version=3.3.0.4000 of NHibernate in your bin directory? It looks like you have a different build of NHibernate in your bin directory.

If you sure it is there, check if your references are correct:

Do you have a reference in your project to:

"System.Data.SqlServerCe"

This is located in the following dir:

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

Make sure you have:

"Copy Local" to true.
分享给朋友:
您可能感兴趣的文章:
随机阅读: