oracle / dotnet-db-samples

.NET code samples for Oracle database developers #OracleDotNet
http://otn.oracle.com/dotnet
MIT License
408 stars 190 forks source link

Could not load file or assembly 'System.DirectoryServices.Protocols, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' #306

Closed anshriv closed 11 months ago

anshriv commented 11 months ago

I have a dotnet core application with following dependency:

<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.90" />

When, i run the program to connect to oracle db, I get following error

Could not load file or assembly 'System.DirectoryServices.Protocols, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Oracle.ManagedDataAccess
 at OracleInternal.ConnectionPool.PoolManager`3.CreateNewPR(Int32 reqCount, Boolean bForPoolPopulation, ConnectionString csWithDiffOrNewPwd, OracleConnection connRefForCriteria, String instanceName, List`1 switchFailedInstNames)
   at OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch)
    at OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch)
    at OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword, OracleConnection connRefForCriteria)
    at Oracle.ManagedDataAccess.Client.OracleConnection.Open()
    at System.Data.Common.DbConnection.OpenAsync(CancellationToken cancellationToken)
 --- End of stack trace from previous location ---

Can someone help, why is it so? If I import , will my error go away?

alexkeh commented 11 months ago

@anshriv Are you using LDAP in your ODP.NET app? If so, you need to add the System.DirectoryServices and System.DirectoryServices.Protocols NuGet packages. LDAP is not used for most ODP.NET apps, which is why these packages are not requirements.