I have created a application which connection to sql server database as well as oracle database
The application is working fine at my end
And to connect to oracle i used following namespace
using Oracle.DataAccess;
using Oracle.DataAccess.Client;
But when i run the application on user end
It gives following exception
the type initializer for Oracle.DataAccess.Client.OracleConnection threw an exception
And I am giving only exe, config file

5
Contributors
5
Replies
12
Views
5 Years
Discussion Span
Last Post by AndrewGrinder

Are the Oracle assemblies installed on the client's machine?

I have developed the application on remote desktop there its working fine
How to install Oracle assemblies on client machine

Type initializers can fail for a number of reasons. The exception being thrown should have an InnerException with more detail as to why initialization failed.

Hello,

This error is occuring because of assembly type mismatch. Try updating the assembly version which you have when/where your program is working fine.

Ok, when you know for sure other applications that used the same process worked... on your new application make sure you have the reference and the three dll files...

I downloaded ODAC1120320Xcopy_32bit this from the Oracle site:

http://www.oracle.com/technetwork/database/windows/downloads/utilsoft-087491.html

Reference: Oracle.DataAccess (ODAC1120320Xcopy_32bit\odp.net4\odp.net\bin\4\Oracle.DataAccess.dll)

3 Files

oci.dll (ODAC1120320Xcopy_32bit\instantclient_11_2\oci.dll)

oraociei11.dll (ODAC1120320Xcopy_32bit\instantclient_11_2\oraociei11.dll)

OraOps11w.dll (ODAC1120320Xcopy_32bit\odp.net4\bin\OraOps11w.dll)

When I tried to create another application with the correct reference and files I would receive that error message.

The fix: Highlighted all three of the files and selected "Copy To Output" = Copy if newer. I did copy if newer since one of the dll's is above 100MB and any updates I do will not copy those files again.

I also ran into a registry error, this fixed it.

public void checkRegistryForOracleNLS()
{
RegistryKey oracle = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\ORACLE");
oracle.SetValue("NLS_LANG", "AMERICAN_AMERICA.WE8MSWIN1252");
}


After that everything worked smooth, I hope it helps.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.