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.
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.
User contributions licensed under CC BY-SA 3.0