Reputation: 57
I try to make select from Oracle 11gR2 by using ODP.NET x86.
In ConsoleApplication everthing works perfectly, but if I try make same select in my MVC 4 WebApplication (from dependentcy injected service from ClassLibrary) I get this error: Additional information: The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception.
I compile app as Any CPU.
Any Idea ? I am lost. Thank s a lot.
ConnectionString
string connectionString = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=kango))); User ID=system; Password=root";
Instantiate
using (var connection = new OracleConnection(connectionString))
{
var command = new OracleCommand(select);
try
{
command.Connection = connection;
connection.Open();
OracleDataReader reader = command.ExecuteReader();
while (reader.HasRows)
{ ...
}
}
}
In ,,using" line exception is thrown
Upvotes: 0
Views: 879
Reputation: 59456
Another solution is to install both 32bit (x86) and 64bit (x64) Oracle client on your machine. Here is an instruction how to do this in order to make them working togeter: Install Oracle Client x86 and x64
Upvotes: 0
Reputation: 52107
Why didn't you post the exception (error message and call stack)? It often contains crucial information for figuring-out the problem.
Absent that, my hunch is that your "Any CPU" build got executed as 64-bit, which caused it to fail loading 32-bit native Oracle DLLs. Solutions to consider:
Upvotes: 1