The system cannot find the file specified. File name: 'System.Configuration.ConfigurationManager, Ve — oracle-tech

    Forum Stats

  • 3,715,918 Users
  • 2,242,907 Discussions
  • 7,845,683 Comments

Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

The system cannot find the file specified. File name: 'System.Configuration.ConfigurationManager, Ve

User_P3LP3
User_P3LP3 Member Posts: 2
edited August 2020 in ODP.NET

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

Tagged:

Answers

  • Alex Keh-Oracle
    Alex Keh-Oracle Posts: 2,752 Employee
    edited August 2020

    I believe you need to add the System.Configuration.ConfigurationManager assembly to your app. You can get this from NuGet Gallery.

  • User_P3LP3
    User_P3LP3 Member Posts: 2
    edited August 2020

    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.QueueUserWorkItemCallback.<>c.<.cctor>b__6_0(QueueUserWorkItemCallback quwi)

       at System.Threading.ExecutionContext.RunForThreadPoolUnsafe[TState](ExecutionContext executionContext, Action`1 callback, TState& state)

       at System.Threading.QueueUserWorkItemCallback.Execute()

       at System.Threading.ThreadPoolWorkQueue.Dispatch()

       at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

    D:\VisualBasic\ConsoleApp1\bin\Debug\netcoreapp3.1\ConsoleApp1.exe (process 15552) 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 . . .

    I am thrown with this error instead. I tried searching for this assembly but I can't find it in the NuGet gallery.

  • Alex Keh-Oracle
    Alex Keh-Oracle Posts: 2,752 Employee
    edited August 2020

    I think you may be using managed ODP.NET (for .NET Framework) instead of ODP.NET Core (for .NET Core) in your app. Did you load Oracle.ManagedDataAccess (managed ODP.NET) or Oracle.ManagedDataAccess.Core (ODP.NET Core) from NuGet Gallery? If it's the former, then remove it and download the latter.

Sign In or Register to comment.