Hi, i am trying to display data from a table in my database using ConsoleApp, but it would not be displayed instead I am shown with this message in the cmd prompt
The type initializer for 'OracleInternal.Common.ProviderConfig' threw an exception.
System.IO.FileNotFoundException: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
File name: 'System.Configuration.ConfigurationManager, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
at OracleInternal.Common.ConfigBaseClass.GetInstance(Boolean bIsManaged)
at OracleInternal.Common.ProviderConfig..cctor()
System.Collections.ListDictionaryInternal
D:\VisualBasic\ConsoleApp1\bin\Debug\netcoreapp3.1\ConsoleApp1.exe (process 21988) exited with code 0.
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .
This is my code on my Console App;
using System;
using System.Data;
using Oracle.ManagedDataAccess.Client;
using Oracle.ManagedDataAccess.Types;
namespace HelloWorld
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
try
{
string conString = "User Id=test;Password=test123;" +
"Data Source=localhost:1521//orcl;Pooling=fasle;";
OracleConnection con = new OracleConnection();
con.ConnectionString = conString;
con.Open();
OracleCommand cmd = con.CreateCommand();
cmd.CommandText = "select first_name from persons";
OracleDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Console.WriteLine("Person Name: " + reader.GetString(0));
}
Console.WriteLine();
Console.WriteLine("Press 'Enter' to continue");
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.InnerException);
Console.WriteLine(ex.Data);
}
//Console.WriteLine("Hello World!");
}
}
}
The code above exited with code 0, and I am able to view my table on my server explorer tab. Can someone help me out, cause I'm new to ODAC and .net
Thank you