Sunday, March 9, 2008

Getting 2 .NET applications to use different Oracle Clients

It is not necessarily evident how to get 2 .NET applications to use 2 different Oracle clients on the same server. The following are some rough notes, but you should get the idea and hopefully save you some time as well.

Information can be found at
http://www.oracle.com/technology/tech/windows/odpnet/faq.html

But I will document what I found.

1. Getting the .NET applications to use the appropriate clients on my development machine

I had to follow some steps to get the different .NET applications to use the appropriate Oracle client.

http://www.oracle.com/technology/tech/windows/odpnet/faq.html

Building a website with Oracle 92:
1. Close Visual Studio
2. Uninstall all Oracle Dlls to remove any 102 references
3. Install only the 9.2 Oracle dlls to the GAC:
4. Set Path with "C:\oracle\ora92\bin;" at the start of the Path environment variable
5. Start Visual Studio and Add Reference the first OracleDataAccess dll (despite what the version # says) to the project
6. Set the dll Copy Local to true for some reason then it compiles
7. Run the app and verify that the right dll is being used
Building a website with Oracle 102:
1. Close Visual Studio
2. Ensure that the 102 Oracle Dlls are in the GAC:
3. Set Path with "C:\oraclexe\app\oracle\product\10.2.0\server\BIN\;" at the start of the Path environment variable
4. Start Visual Studio and Add Reference the first OracleDataAccess dll (despite what the version # says) to the project
5. Run the app and verify that the right dll is being used



uninstall All Oracle GAC dlls
"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" /u Oracle.DataAccess
"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" /u Policy.9.2.Oracle.DataAccess
"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" /u Policy.10.1.Oracle.DataAccess



10.2.0.1 GAC install
"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" /i C:\oraclexe\app\oracle\product\10.2.0\server\BIN\Oracle.DataAccess.dll
"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" /i C:\oraclexe\app\oracle\product\10.2.0\server\ODP.NET\PublisherPolicy\Policy.10.1.Oracle.DataAccess.dll


9.2 GAC install only
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\gacutil.exe /i C:\oracle\ora92\bin\Oracle.DataAccess.dll

Your application can do a simple ""select count(*) on table" to verify functionality. To find out which dll you are exactly using, you can use
Type ttt = typeof(OracleConnection);
mes += "\n ttt.Assembly.FullName";



2. Note that setting the path variables for Windows Server does not help out the same as on XP

The path can be set in the application via setting the DLL path in the application itself as follows:

Inside Global.asax.cs:

[DllImport("kernel32.dll",SetLastError=true)]
static extern bool SetDllDirectory(string lpPathName);
protected void Application_Start(Object sender, EventArgs e)
{
string dllPath = ConfigurationSettings.AppSettings["DllPath"];
bool result = SetDllDirectory(dllPath);
}


Inside Web.config

<appsettings>
<add key="DllPath" value="D:\oracle\Client_10g_1010\BIN">
</add>
</appsettings>

2 comments:

Anonymous said...

vab банк
vab банк
[url=http://www.ricardo.com.ua/news/releases/110220]vab банк[/url]
http://www.ricardo.com.ua/news/releases/110220 - vab банк

Anonymous said...

Ygxstm [url=http://hermeskelly.finniwolf.com][b]cheap hermes[/b][/url] foulard a prix discount http://hermeskelly.finniwolf.com Zclwbh Cqgwin hermes outlet