Kshitij Sinha
Kshitij Sinha

Reputation: 21

Connecting with Oracle Database fails

Code:

private void Button_Click_6(object sender, RoutedEventArgs e)
{
    TimerView tobj = new TimerView();
    tobj.Show();
    string OracleServer = "Data Source=(DESCRIPTION="
+ "(ADDRESS=(PROTOCOL=TCP)(HOST=DLDT-0897.nectechnologies.in)(PORT=1521))"
+ "(CONNECT_DATA=(SERVICE_NAME=XE)));"
+ "User ID=system;Password=abc@1234;";
     public bool Open()
{
    try
    {
        conn = new OracleConnection(OracleServer);
        conn.Open();
        return true;
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
    return false;
}

Error in conn.Open():

Warning 1 There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "Oracle.DataAccess, Version=4.112.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=AMD64", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. WpfApplication

Upvotes: 2

Views: 1376

Answers (1)

Patrick Hofman
Patrick Hofman

Reputation: 157136

The ODP.NET package comes in two flavors: one for 32 bits programs and one for 64 bit programs. You have to pick one when you compile since else you might end up in trouble when running the program. So you have to switch from MSIL to 32-bits mode preferably (to support both processor architectures). You need to include the 32-bits version of ODP.NET then (now you are using 64-bits).

A better option might be to use the managed ODP.NET library, which supports both processor architectures since it doesn't depend on OCI any more. You can find the latest version here.

Upvotes: 1

Related Questions