问题
I'm using the Oracle ODP.Net 11.2.0.2 provider to connect to an Oracle database. When I run the following code as a Console application, the creation of the OracleConnection object takes over 2 minutes:
using System;
using Oracle.DataAccess.Client;
namespace OracleConnectionTest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Creating connection...");
OracleConnection conn = new OracleConnection("Data Source=mydatabase;User Id=myuserid;Password=mypassword");
Console.WriteLine("Opening connection...");
conn.Open();
Console.WriteLine("Closing connection");
conn.Close();
Console.WriteLine("Done");
}
}
}
The slow creation occurs whether I run the console application from the command line or from Visual Studio. However, if I run it with the debugger enabled (using F5), then it runs extremely quickly. If I compile the .Net project as 64-bit (and use the 64-bit Oracle client) it runs quickly. If I create the connection in a Windows Service application and start the service, it connects quickly. A co-worker is able to run the same code with the same 32-bit client installed and it runs quickly for him.
There must be something unique to my environment causing the slowdown. Where would I look to determine what is happening?
回答1:
Try creating the "log\diag\clients" directory structure in your Oracle home. See this blog post - the blogger had the same problem you had and resolved it by creating that directory structure.
来源:https://stackoverflow.com/questions/15009090/creating-32-bit-odp-net-oracleconnection-object-is-very-slow