I'm doing a program in C # that attacks an Oracle 12C database that is in another virtual machine, if I connect using SQL Developer I have no problems, I connect and I can work.
Now I try to enter from code and I get the error indicated in the title of the question The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception.
The connection string is as follows:
Data Source=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.87)(PORT = 1521))
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = PRUEBA)));
User Id=SYSTEM;Password=PASS;
I have tried using version v4.0.30319 of Oracle.DataAccess and also version v2.0.50727.
I compiled for x86 and for Any CPU.
The database is in a 64-bit WINDOWS SERVER 2012 R2 Standar.
I have verified that there is ping in both directions of the machines.
I'm a little desperate because I do not know what else to try, if someone can help me I would be very grateful.
P.D: The name of the service is not PROOF but for security we will do as if it were
Edit 1:
_cnn_string = this.tCadena.Text.ToString();
this._cnn = new OracleConnection(_cnn_string);
try
{
this._cnn.Open();
MessageBox.Show("Conexión correcta!");
}
catch (Exception ex)
{
MessageBox.Show("Error!: " + ex.Message);
}
finally
{ this._cnn.Close(); }
The connection string is set in a textbox bareback to make the tests and is as follows:
Data Source=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.87)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = PRUEBA)));User Id=SYSTEM;Password=PASS;