Ahmed Gaber
Ahmed Gaber

Reputation: 708

Oracle instant client with C# windows forms application

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

Upvotes: 4

Views: 8288

Answers (3)

Fritz
Fritz

Reputation: 472

Look at this thread: The provider is not compatible with the version of Oracle client

The DLLs listed there did the job for me (All in the same directory as the exe).

Upvotes: 0

Stritof
Stritof

Reputation: 850

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)

Upvotes: 2

Shaun Campbell
Shaun Campbell

Reputation: 51

ODP.net is fussy about mixing version numbers. The error message:

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()

indicates that its picking up the wrong client DLL version somewhere. When I did some development with Oracle and Visual C# 2010 I downloaded the ODP.NET libraries from:

http://www.oracle.com/technetwork/developer-tools/visual-studio/downloads/index.html

I then took the correct version for the version of Oracle I would be working with and used those DLLs in my project. I'm not sure what the restrictions are in redistribution though.

Upvotes: 0

Related Questions