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!

Oracle.ManagedDataAccess throws Exceptions from the Finalize block if constructor fails

e07573ea-66f1-448e-8907-aa92d40aa45cJan 16 2019 — edited Jan 16 2019

I am running .Net 4.5.2 and Oracle 12. Today I updated Oracle.ManagedDataAccess to nuget version 18.3.0 and made the mistake to set version in app.config to Version=18.3.0 instead of the correct Version=4.122.18.3

This gave the error
The type initializer for 'OracleInternal.Common.ProviderConfig' threw an exception. ---> System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for oracle.manageddataaccess.client: Could not load file or assembly 'Oracle.ManagedDataAccess, Version=18.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
and surprisingly enough this made the application crash

I say surprising since the call to Oracle is wrapped in exception block that by logic should capture any exceptions inside...but that does not hold true in this particular case when I have a using block which makes the Finalize() code run when the object goes out of scope after the main exception has been caught in my catch expression.

Expected behavior should be that Finalize must never throw an exception even if the constructor fails. When I am using the right Version information everything works, but this kind of mistake with setting version information incorrectly is bound to happen again and again so please fix this bug so that users of Oracle.ManagedDataAccess must not deal with such unhandled exceptions.

The actual stack trace:

System.TypeInitializationException: The type initializer for 'OracleInternal.Common.ProviderConfig' threw an exception. ---> System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for oracle.manageddataaccess.client: Could not load file or assembly 'Oracle.ManagedDataAccess, Version=18.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) (C:\Utveckling_git\Trafikdata\Server\TD.Server.Start\bin\AST_STHLM\TD.Server.Start.exe.Config line 18) ---> System.IO.FileLoadException: Could not load file or assembly 'Oracle.ManagedDataAccess, Version=18.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

   at System.Configuration.TypeUtil.GetTypeWithReflectionPermission(IInternalConfigHost host, String typeString, Boolean throwOnError)

   at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.Init(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)

   at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.InitWithRestrictedPermissions(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)

   at System.Configuration.RuntimeConfigurationRecord.CreateSectionFactory(FactoryRecord factoryRecord)

   at System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String configKey, Boolean& isRootDeclaredHere)

   --- End of inner exception stack trace ---

   at System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String configKey, Boolean& isRootDeclaredHere)

   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)

   at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)

   at System.Configuration.ConfigurationManager.GetSection(String sectionName)

   at OracleInternal.Common.CustomConfigFileReader.ParseAndCacheConfigParams()

   at OracleInternal.Common.CustomConfigFileReader.ParseConfigFile()

   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 TD.Server.Report.TDODPReportService.GetMatplatsDateRange(TDMatplats matplats, Int32 logger) in c:\Utveckling_git\Trafikdata\Server\TD.Server.Report\TDODPReportService.cs:line 216

2019-01-16 09:26:13,477 DEBUG  Logger: [generalLogger]

   at Oracle.ManagedDataAccess.Client.OracleConnection..ctor(String connectionString)

   at TD.Server.Report.TDODPReportService.GetMatplatsDateRange(TDMatplats matplats, Int32 logger) in c:\Utveckling_git\Trafikdata\Server\TD.Server.Report\TDODPReportService.cs:line 216

2019-01-16 09:26:13,581 FATAL  Logger: [generalLogger]

The application terminated due to UnhandledException

System.TypeInitializationException: The type initializer for 'OracleInternal.Common.ProviderConfig' threw an exception. ---> System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for oracle.manageddataaccess.client: Could not load file or assembly 'Oracle.ManagedDataAccess, Version=18.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) (C:\Utveckling_git\Trafikdata\Server\TD.Server.Start\bin\AST_STHLM\TD.Server.Start.exe.Config line 18) ---> System.IO.FileLoadException: Could not load file or assembly 'Oracle.ManagedDataAccess, Version=18.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

   at System.Configuration.TypeUtil.GetTypeWithReflectionPermission(IInternalConfigHost host, String typeString, Boolean throwOnError)

   at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.Init(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)

   at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.InitWithRestrictedPermissions(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)

   at System.Configuration.RuntimeConfigurationRecord.CreateSectionFactory(FactoryRecord factoryRecord)

   at System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String configKey, Boolean& isRootDeclaredHere)

   --- End of inner exception stack trace ---

   at System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String configKey, Boolean& isRootDeclaredHere)

   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)

   at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)

   at System.Configuration.ConfigurationManager.GetSection(String sectionName)

   at OracleInternal.Common.CustomConfigFileReader.ParseAndCacheConfigParams()

   at OracleInternal.Common.CustomConfigFileReader.ParseConfigFile()

   at OracleInternal.Common.ConfigBaseClass.GetInstance(Boolean bIsManaged)

   at OracleInternal.Common.ProviderConfig..cctor()

   --- End of inner exception stack trace ---

   at Oracle.ManagedDataAccess.Client.OracleConnection.Finalize()

Comments
Post Details
Added on Jan 16 2019
5 comments
12,934 views