Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem running dotnet Core Example in VS Code - (ODP.NET Database Connections: Using Connect Descri

user552932Aug 7 2019 — edited Aug 7 2019

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

OraError.PNG

The code is very simple

using System;

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.

This post has been answered by user552932 on Aug 7 2019
Jump to Answer

Comments

OrionNet
Api,

You can simply create new temporary tablespace in new location and set it as default temporarty tablespace. And similar you can do that with undo tablespace
sqlplus '/as sysdba'


SQL>CREATE TEMPORARY TABLESPACE temp2   TEMPFILE '/new_location/temp2_01.dbf' SIZE 64M REUSE AUTOEXTEND ON NEXT 28 MAXSIZE unlimited;

SQL>ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp2

#drop old temp tablespace
SQL>DROP TABLESPACE temp INCLUDING CONTENTS AND DATAFILES;


#undo tablespace

SQL>create undo tablespace undotbs2 datafile '/new_location/newundo02.dbf' size 2000m;

#Set new tablespace as undo tablespace
SQL> alter system set undo_tablespace= undotbs2 ;

#Drop old undotbs tablespace
SQL> drop tablespace undotbs including contents;
Regards
sb92075
I want to move my undo and temporary tablespace to new path because of space issue.
I am using Oracle 10g release 2 and working on production server can't take shutdown without prior permission.
Create new UNDO & TEMP tablespaces, switch to new TS, & then drop old ones.
Surachart Opun
About create/change/drop

UNDO:

SQL>show parameter undo

NAME TYPE VALUE
------------------------------------
undo_management string AUTO
undo_retention integer 900
undo_tablespace string UNDOTBS1

SQL> CREATE UNDO TABLESPACE undotbs2 DATAFILE '+DATA_NEWPATH' SIZE 100M AUTOEXTEND ON;

http://www.oracle-base.com/articles/9i/AutomaticUndoManagement.php

SQL> alter system set undo_tablespace=undotbs2;

*** after that can drop UNDOTBS1

TEMP:
SQL> CREATE TEMPORARY TABLESPACE TEMP TEMPFILE '+DATA_NEWPATH' SIZE 500M AUTOEXTEND ON NEXT 100M MAXSIZE unlimited EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;

http://www.idevelopment.info/data/Oracle/DBA_tips/Tablespaces/TBS_3.shtml

SQL> ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp2;


*** after that can drop old temp tablespace -> DROP TABLESPACE temp INCLUDING CONTENTS AND DATAFILES
708725
Ya thanks a lot for the answer but I have one more query...

Mine is the production server and I can't shutdown so may I do all this operation when database is open?

How do I know that users are accessing the old Undo tablespace or temporary tablespace or not, because after checking that no one is using the old ones, I can drop it. So when can I drop old undo and temp tablespaces?
oradba11
If you are trying to drop these tablespace ..which is being use by some transactions ..oracle will not allow to do that..
Read some documents on google ..thay will clear you doubts also..

enjoy
1 - 5

Post Details

Added on Aug 7 2019
1 comment
9,271 views