问题描述
我继承了C#/NHibernate/MS SQL Server项目,并且是NHibernate的新手.给我的首要任务之一是将数据库从MS SQL Server(2008 R2)迁移到Postgresql 9.2.我正在使用Npgsql 2.0.12(.net 2.0版本). Mono.Security.dll和Npgsql.dll包含在我的项目引用中,它们存在于我的bin目录中.当代码执行以下行时:
I've inherited a C#/NHibernate/MS SQL Server project and am new to NHibernate. One of the first tasks given to me was to migrate the database from MS SQL Server (2008 R2) to Postgresql 9.2. I'm using the Npgsql 2.0.12 (.net 2.0 version). The Mono.Security.dll and Npgsql.dll are included in my project References and they exist in my bin directory. When the code executes the following line:
SessionFactory.OpenSession();
消息抛出异常
无法从NHibernate.Driver.NpgsqlDriver创建驱动程序."
"Could not create the driver from NHibernate.Driver.NpgsqlDriver."
在网络上搜索,给了我一些想法,但没有一个起作用.我继承的这段代码正在使用MS SQL Server的多个客户端上投入生产.这是我的hibernate.cfg.xml文件:
Searching the web, gave me a few ideas but none have worked. This code I've inherited is in production at several clients with no issues using MS SQL Server. Here is my hibernate.cfg.xml file:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.PostgreSQLDialect</property>
<property name="connection.driver_class">NHibernate.Driver.NpgsqlDriver</property>
<property name="connection.connection_string">server=localhost;Port=5432;Database=vehicletracker;User Id=postgres;Password=********;</property>
</session-factory>
</hibernate-configuration>
我没有忘记添加"using Npgsql;",它就在那里.有什么建议吗?
I did not forget to include "using Npgsql;", it is there. Any suggestions?
此致
B
推荐答案
我找到了自己问题的答案.我的工作环境存在一些特定的问题,但是最终我的最终输出目录中没有Mono.Security.dll和Npgsql.dll.这两个文件存在于我的数据访问层(一个类库)的bin目录中,而不存在于我的称为类库的Test Project的bin目录中.现在一切正常.
I found the answer to my own question. There were several issues specific to my work environment but ultimately the Mono.Security.dll and Npgsql.dll were not available in my final output directory. The two files were present in the bin directory of my Data Access Layer (a class library) but not in the bin directory of my Test Project that called the class library. Everything is working fine now.
这篇关于无法从NHibernate.Driver.NpgsqlDriver创建驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!