Skip to content

ODP.Net - Visual Studio 2022 connection  #313

Description

@twm1005

Switching to using an Oracle Wallet. I have verified that I can connect via SQL developer and programmatically via .NET PowerShell using Oracle.ManagedDataAccess.dll (both Core and Framework). I'm trying to not install Oracle Client and just use extended connection strings.

This works in PowerShell:

        Add-Type -Path "Oracle.ManagedDataAccess.dll"
        $connectionString = "Data Source=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCPS)(HOST = XXXl )(PORT = 2484))(CONNECT_DATA = (SID = XXX)));User ID=XXX;Password=XXX!;Wallet_Location=c:\Users\XX\Documents\XX\wallet_v5;"
        $con = New-Object Oracle.ManagedDataAccess.Client.OracleConnection($connection_string)
        $con.Open()

I'm having an issue connecting to the same database with the wallet via:

  1. Visual Studio 2022 - Server Explorer (tried via TNS alias and Advanced)
  2. Oracle Developer Tools for VS Code (SQL and PLSQL) - New connection (tried TNSNAMES and ODP.NET connection string.
  3. programmatically in C# using core.

Here is how I'm trying in C# Razor

OracleConfiguration.WalletLocation = @"(SOURCE = (METHOD = file)(METHOD_DATA = (DIRECTORY=c:\Users\XXX\Documents\XXX\wallet_v5)))";
OracleConfiguration.SqlNetWalletOverride = true;
OracleConfiguration.SqlNetAuthenticationServices = "(TCPS)";
OracleConfiguration.OracleDataSources.Add("DEV", "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCPS)(HOST=XXX)(PORT=2484))(CONNECT_DATA=(SID=XXX)(SERVER=dedicated)))");
OracleConfiguration.StatementCacheSize = 25;
OracleConfiguration.SelfTuning = false;
OracleConfiguration.BindByName = true;
OracleConfiguration.CommandTimeout = 60;
OracleConfiguration.FetchSize = 1024 * 1024;
OracleConfiguration.SendBufferSize = 8192;
OracleConfiguration.DisableOOB = true;
OracleConfiguration.TraceOption = 1;
OracleConfiguration.TraceFileLocation = @"C:\RBI";
OracleConfiguration.TraceLevel = 7;
OracleConnection orclCon = null;
orclCon = new OracleConnection("User ID=XXX;Password=XXX;data source=DEV");
orclCon.Open();

Seems the difference is the ODP.Net tools for Visual Studio and VS Code. But I copied the Oracle.ManagedDataAccess.dll from my VS solution and used it sucessfully in my test powershell script.

I get the following error in C# and VS Code:

Oracle.ManagedDataAccess.Client.OracleException: 'Oracle Communication: Failed to connect to server or failed to parse connect string'
This exception was originally thrown at this call stack:
    System.Collections.CollectionBase.System.Collections.IList.get_Item(int)
    System.Security.Cryptography.X509Certificates.X509CertificateCollection.this[int].get(int)
    OracleInternal.Network.TcpsTransportAdapter.Negotiate(OracleInternal.Network.ConnectionOption)
    OracleInternal.Network.TcpsTransportAdapter.ConnectIterate()
    OracleInternal.Network.OracleCommunication.ConnectViaCO(OracleInternal.Network.ConnectionOption, OracleInternal.Network.AddressResolution)

For Server Explorer: I get Failure during SSL handshake.

I don't understand why I can connect via PowerShell but nowhere else.
I tried placing tnsnames/sqlnet files in bin/* and root of application.
I attached my last trace file.
Any help would be much appreciated.

RBI.EXE_PID_25164_TID_1_DATE_2023_09_25_TIME_11_26_38_060982.trc.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions