1

我正在使用C#Windows窗体应用程序在Windows Server 2008 R2 Enterprise x64中使用NHibernate连接Oracle 11g数据库。我用了NHibernate的跟随配置:Oracle驱动程序与Windows Server x64中的NHibernate连接

string connectionProvider = "NHibernate.Connection.DriverConnectionProvider"; 
string dialect = "NHibernate.Dialect.Oracle10gDialect"; 
//to use OracleDataClientDriver (ODP.NET), must configure the appropriated "Plataform Target". 
//In Windows Server, is not possible work with ODAC x64, because the Windows Form Application don't accept 
//"Platform Target" = "Any CPU" configuration. For this, it was intalled the ODAC1120320_32bit 
connectionDriver = "NHibernate.Driver.OracleDataClientDriver"; 
string connectionString = ... 

它工作了几天,但现在,错误“无法创建NHibernate.Driver.OracleDataClientDriver司机。”出现。 C#项目配置如下图所示: enter image description here 我真的不知道我需要做更多的测试,因为32位和64位的ODAC已经安装并且未被阻塞。请帮忙。谢谢。

+0

你知道'NHibernate.Driver.OracleDataClientDriver'是否违背你的64位或你的32位ODAC? – DWright 2015-03-18 22:59:08

+0

对不起,我不明白你的问题。安装的ODAC是ODAC1120320_32bit(奇怪的是:这个在两周前的测试中有效)。 SO是64位,应用中的平台目标是32位(与ODAC一致)。这回答你的问题?谢谢 – 2015-03-19 00:09:19

+0

我从odac客户端文件夹引用C#中的odp.net dll。 – 2015-03-19 00:13:04

回答

2

如果您使用的是Nhibernate 4,则可以使用OracleManagedDataClientDriver和odp.net管理的驱动程序(https://www.nuget.org/packages/odp.net.managed/)。这是一个“任何客户端”驱动程序,你不会在机器上安装任何东西。它使得支持Oracle变得更加容易。不再需要将ODAC .dll复制到您的部署目录。

+0

完美。因为我在Windows Server 2008中工作,所以这不允许Visual Studio 2013(使用nuget包),然后我使用了这篇文章的第二个答案:http://stackoverflow.com/questions/4566908/how-can -i - 使用 - 的NuGet与 - 视觉-C-尖锐快车。谢谢弗兰。 – 2015-03-19 17:04:36

相关问题