2
votes

I'm writing a console application that requires data to be pulled from a database. When I use the following line to create the connection object, it throws a FileNotFoundException.

OracleConnection con = new OracleConnection();

I've installed and included the Oracle Managed Data Access Client, and I've attempted to rewrite the definition multiple ways, including passing the connection string in the definition, but it always throws the same exception.

Here's the exact message:

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(String connectionString) at SecurityAwareness.Program.Main(String[] args) in "directory"

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.

1
Did you install via Nuget? If not, do that -- it will handle any dependencies; which I suspect you might be lackingHambone
I did install through nuget. I tried using the most recent version, and also tried rolling back to another previous version.dzeleniak0
Can you provide us with more code(if you can)? For, me I installed the package via NuGet and instatiated perfectly.Calin Vlasin
@adsad No code required I suspect. The missing dll is System.Configuration.ConfigurationManager, a standard .net framework library. Sounds more as an install problem (of framework or Oracle assembly)Gian Paolo

1 Answers

5
votes

You do not mention which .NET you are using. I had the same error. I was building an app using the WebApi2, which uses the .NET Core 2.x instead of the .NET 4.x.

I switched to the Oracle.ManagedDataAccess.Core (2.18) NuGet Package and then the error went away, and I was able to connect to my Oracle Database using the simple Oracle Connection code.