- 3,715,652 Users
- 2,242,819 Discussions
- 7,845,478 Comments
Forum Stats
Discussions
Categories
- 17 Data
- 362.2K Big Data Appliance
- 7 Data Science
- 1.6K Databases
- 466 General Database Discussions
- 3.7K Java and JavaScript in the Database
- 22 Multilingual Engine
- 487 MySQL Community Space
- 3 NoSQL Database
- 7.6K Oracle Database Express Edition (XE)
- 2.8K ORDS, SODA & JSON in the Database
- 416 SQLcl
- 42 SQL Developer Data Modeler
- 184.8K SQL & PL/SQL
- 21K SQL Developer
- 1.9K Development
- 3 Developer Projects
- 32 Programming Languages
- 135.1K Development Tools
- 8 DevOps
- 3K QA/Testing
- 247 Java
- 5 Java Learning Subscription
- 10 Database Connectivity
- 66 Java Community Process
- 1 Java 25
- 9 Java APIs
- 141.1K Java Development Tools
- 6 Java EE (Java Enterprise Edition)
- 153K Java Essentials
- 135 Java 8 Questions
- 86.2K Java Programming
- 270 Java Lambda MOOC
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 10 Java SE
- 13.8K Java Security
- 3 Java User Groups
- 22 JavaScript - Nashorn
- 18 Programs
- 125 LiveLabs
- 30 Workshops
- 9 Software
- 3 Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 3 Deutsche Oracle Community
- 10 Español
- 1.9K Japanese
- 2 Portuguese
Problem running dotnet Core Example in VS Code - (ODP.NET Database Connections: Using Connect Descri

Hi there … hope someone can help
I have tried to follow the tutorial (ODP.NET Database Connections: Using Connect Descriptors and Net Service Names) from Alex Keh - https://www.youtube.com/watch?v=k3wLHQALZRk
But find that I am having problems with the Oracle.ManagedDataAccess.Client
Using VS Code
Building an identical console App as in the tutorial – but when try to run get the following error
Exception has occurred: CLR/System.TypeInitializationException
An unhandled exception of type 'System.TypeInitializationException' occurred in Oracle.ManagedDataAccess.dll: 'The type initializer for 'OracleInternal.Common.ProviderConfig' threw an exception.'
Inner exceptions found, see $exception in variables window for more details.
Innermost exception System.IO.FileNotFoundException : Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
at OracleInternal.Common.ConfigBaseClass.GetInstance(Boolean bIsManaged)
at OracleInternal.Common.ProviderConfig..cctor()
Also, see the following in the terminal
Executing task: C:\Program Files\dotnet\dotnet.exe build C:\Users\u203379\MyWork\ASPNet\core_console_ora/core_console_ora.csproj /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary <
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
C:\Users\u203379\MyWork\ASPNet\core_console_ora\core_console_ora.csproj : warning NU1701: Package 'Oracle.ManagedDataAccess 19.3.1' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.2'. This package may not be fully compatible with your project.
Restore completed in 28.4 ms for C:\Users\u203379\MyWork\ASPNet\core_console_ora\core_console_ora.csproj.
C:\Users\u203379\MyWork\ASPNet\core_console_ora\core_console_ora.csproj : warning NU1701: Package 'Oracle.ManagedDataAccess 19.3.1' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.2'. This package may not be fully compatible with your project.
core_console_ora -> C:\Users\u203379\MyWork\ASPNet\core_console_ora\bin\Debug\netcoreapp2.2\core_console_ora.dll
Terminal will be reused by tasks, press any key to close it.
Here is a screenshot
The code is very simple
using Oracle.ManagedDataAccess.Client;
using Oracle.ManagedDataAccess.Types;
namespace core_console_ora
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World! Lets try and connect to Oracle");
string Development_UserPass = "USer Id=u203379;Password=************;";
string Develoment_Connect = "Data Source=dfargs03-scan:1521/GISAENTW;";
string connectionstring = Development_UserPass + Develoment_Connect ;
OracleConnection con = new OracleConnection();
con.ConnectionString = connectionstring;
con.Open();
OracleCommand cmd = con.CreateCommand();
cmd.CommandText = "select user from dual" ;
OracleDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Console.WriteLine("DB User. " + reader.GetString(0));
}
Console.WriteLine();
Console.WriteLine("Press 'Enter' to continue");
Console.ReadLine();
}
}
}
But errors at line 17 - OracleConnection con = new OracleConnection();
To add Oracle Maanaged Data Access used:
dotnet add package Oracle.ManagedDataAccess --version 19.3.1
dotnet add package Oracle.ManagedDataAccess --version 19.3.1 --framework netcoreapp2.2
Changing, specifying the framework did not solve the problem
Interestingly, I have also added the extension "Oracle Developer Tools for VS Code" and this works without any problem when I use a full connection string or a connection based on TNSNames.
Can anyone tell me how to eliminate this error ...
Many thanks in advance
Update
Just did the same exercise using Visual Studio 2017
And get the following error from the same line ... OracleConnection con = new OracleConnection();
System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for 'OracleInternal.Common.ProviderConfig' threw an exception.
Source=Oracle.ManagedDataAccess
StackTrace:
at Oracle.ManagedDataAccess.Client.OracleConnection..ctor()
Inner Exception 1:
FileNotFoundException: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
Best Answer
-
Problem resolved
A stupid error but had installed the Oracle.ManagedDataAccess package using - this is not the correct Managed Data Access Component
dotnet add package Oracle.ManagedDataAccess --version 19.3.1
dotnet add package Oracle.ManagedDataAccess --version 19.3.1 --framework netcoreapp2.2
Remove the one above and install the correct one for dotnet core using
dotnet add package Oracle.ManagedDataAccess.Core --version 2.19.31
It is quite easy to mix the two up...
Answers
-
Problem resolved
A stupid error but had installed the Oracle.ManagedDataAccess package using - this is not the correct Managed Data Access Component
dotnet add package Oracle.ManagedDataAccess --version 19.3.1
dotnet add package Oracle.ManagedDataAccess --version 19.3.1 --framework netcoreapp2.2
Remove the one above and install the correct one for dotnet core using
dotnet add package Oracle.ManagedDataAccess.Core --version 2.19.31
It is quite easy to mix the two up...