Oracle instant client with C# windows forms application

Ahmed Samy picture Ahmed Samy · Jan 7, 2013 · Viewed 7.5k times · Source

I have been looking for this for long time , I have developed Windows Forms App using C # that have to connect Oracle database, this app will be used on many PCs using windows XP and windows 7 After long research i have found that i need to use OBP.net for oracle access but problem is i cannot install oracle client on every PC, However i found work around in CodePorject Exampleto download 5 DLL files to do the same job

OCI Instant Client Data Shared Library
    oraociicus10.dll (Basic-Lite version)
    oraociei10.dll (Basic version)
Client Code Library
    oci.dll
Security Library
    orannzsbb10.dll
OCCI Library
    oraocci10.dll

But when i release the app it dosent connect to Oracle Database Please help how i can have my Windows Forms app connecting Oracle Database with no oracle client installed PC and if this is achievable through the above DLLS how i can do that ?

EDIT:

DataTable dt = new DataTable();
OracleConnection Oracle_connection = new OracleConnection();
Oracle_connection.ConnectionString = con;
Oracle_connection.Open();

got connection timeout, in Oracle_connection.Open(); in debugging mode and I dont use TNSNAMES.ORA as my connection string is as

Data Source=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.20.2.54)(PORT = 1521))(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = PRD))) ;User Id=catering;Password=catering;"`

Tried to publish the code it worked on Windows 7 PC but didnt work on Windows XP System.TypeInitializationException: The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception. ---> Oracle.DataAccess.Client.OracleException The provider is not compatible with the version of Oracle client at Oracle.DataAccess.Client.OracleInit.Initialize()

Dunno if it's windows related or some DLLs are missing

Answer

Stritof picture Stritof · Apr 4, 2013

There is also fully managed .net connector aka ODP.NET Managed Driver:

I've tested it on Windows 8 and Windows XP SP3 with .NET 4.0 framework installed - all working as expected. For deploying, only 1 dll is needed (Oracle.ManagedDataAccess.dll) which weights 6 MB (in comparison with instant client lite which was almost 40 MB).

UPDATE: Probably the best way to use managed oracle driver is via NuGet (ODP.NET @ nuget)