12

Oracle released a beta version driver ODP for dotnet core 2(Finally!). But I can't make it work. Does anybody did it? If yes, please send me the code or help me fixing this one \o

Useful: I am using Visual Code, project "dotnet new mvc" (.net 2) and I installed Oracle.ManagedDataAccess.Client via Nuget Add Package facility (CTRL + P, ...) Here my code:

public static OracleConnection AbrirSigmaUser(AutenticacaoModel autenticacao)
        {
            try
            {

                string _connectionString;

                _connectionString = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.15)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=databaseName)));User Id=UserName;Password=***;";


                OracleConnection conexao = new OracleConnection();
                conexao.ConnectionString = _connectionString;

                //right here the program exit
                conexao.Open();             




                return conexao;
            }
            catch (System.Exception ex)
            {               

                throw new Exception("Não foi possível conectar ao banco de dados!" + "\nErro: " + ex.Message);
            }
        }

The compiler was throwing a lot of exceptions about missing dlls, so I installed them via Nuget Add Package facility:

//required for connection
using Oracle.ManagedDataAccess.Client;
using System.Configuration;
using System.Security.Permissions;
using System.Security.Principal;

After adding all dlls asked, the program goes to conexao.Open() and never comes back, throwing an unhandled exception:

Unhandled Exception: System.TypeLoadException: Could not load type 'System.Security.Principal.WindowsImpersonationContext' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
   at OracleInternal.ConnectionPool.PoolManager`3.CreateNewPRThreadFunc(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
The program '[8860] Sensatta-Analytcs.dll' has exited with code 0 (0x0).

Is all of it really needed to make a simple connection?

If there's something missing(e.g code samples) in order to figure out my issue, just tell me!

2
  • 2
    You mention having added Oracle.ManagedDataAccess.Client while the package name is Oracle.ManagedDataAccess.Core. Is that a typo? Can you show us your dependenceis in .csproj? Commented Mar 8, 2018 at 6:31
  • @Lesiak you could not be more right, thanks! But that is an error someone else might fall in too. Because when you download the zip file from oracle link the dll name is Oracle.ManagedDataAccess.dll Commented Mar 8, 2018 at 11:20

4 Answers 4

30

For me, the solution was to install the Oracle.ManagedDataAccess.Core NuGet package only. I had Oracle.ManagedDataAccess installed as well and I needed to uninstall it to fix the error.

Sign up to request clarification or add additional context in comments.

1 Comment

Yep, that worked for me .net core 2.2 - thanks! I didn't notice before your comment that there is core version
9

As @Lesiak stated, I used the wrong package (the right one is Oracle.ManagedDataAccess.Core.dll). But that is an error someone else might fall in too. Because when you download the zip file from Oracle Link the dll name is Oracle.ManagedDataAccess.dll instead of Oracle.ManagedDataAccess.Core.dll that's error prone.

3 Comments

To be precise, Oracle.ManagedDataAccess.Core is a NuPkg, not a dll. The problem with the link is that the download has a zip extension, not NuPkg. That is the reason why nuget doesn't notice it in local repository.
you will find the "Oracle.ManagedDataAccess.dll" if you unzip the file, inside "~/Oracle.ManagedDataAccess.Core.2.12.0-beta2/lib/netstandard2.0". I had to move it to my project's binary folder "~/bin".
Correct, this is one way to deal with downloaded nupkg. Other is to setup a local nuget repo. But the driver is finally in official NuGet repo, so we don't have to do this.
2

Install Oracle.ManagedDataAccess.Core nuget package to your project.
Make sure code below is included in your .csproj file:

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

Also uninstall "Oracle.ManagedDataAccess" from your project.
Make sure code below is removed from your .csproj file:

<PackageReference Include="Oracle.ManagedDataAccess" Version="19.10.1" />

Comments

0

For me works putting previous version of Oracle.ManagedDataAccess.Core, the last version have any problem.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.