Oracle.ManagedDataAccess Registry is not supported on this platform

447 Views Asked by At

operating system: windows 10 Framework: .Net 6 IDE: Visual Studio 2022 Docker: Linux Container

I am trying to use Oracle.ManagedDataAccess (21.6.1) client.

as soon as I new up the OracleConnection I get an exception

System.TypeInitializationException: The type initializer for 'OracleInternal.Common.ProviderConfig' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'Microsoft.Win32.Registry' threw an exception.
 ---> System.PlatformNotSupportedException: Registry is not supported on this platform.
   at Microsoft.Win32.RegistryKey.OpenBaseKeyCore(RegistryHive hKey, RegistryView view)
   at Microsoft.Win32.Registry..cctor()
   --- End of inner exception stack trace ---
   at OracleInternal.Common.CustomConfigFileReader..ctor(Boolean bIsManaged)
   at OracleInternal.Common.ConfigBaseClass.GetInstance(Boolean bIsManaged)
   at OracleInternal.Common.ProviderConfig..cctor()
   --- End of inner exception stack trace ---
   at Oracle.ManagedDataAccess.Client.OracleConnection..ctor(String connectionString)
   at oracle_test.Controllers.WeatherForecastController.Get() in C:\Src\oracle-test\Controllers\WeatherForecastController.cs:line 43

I have been looking for a docker linux container example using an oracle provider client and I have not been able to find any article or information that can help me with this.

1

There are 1 best solutions below

0
Alexandre Monteiro On

I was facing this error because the project was using the ODP for .NET, but we need to use the ODP for .NET Core version. I'm not using the tnsnames.ora reference too, getting the datasource complete string like

(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=<server_ip>)(PORT=<server_port>))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=<service_name>)))

And, finally, configure connection object instance to ignore timezone, setting OracleConnection.UseHourOffsetForUnsupportedTimezone property.