Share via

.NET Framework WinForms app crashing with Oracle.ManagedDataAccess when Oracle Client 19c (64 bit) is installed (duplicate config issue)

Aman Agrahari 200 Reputation points
2026-05-01T13:41:14.45+00:00

Hi all,

I’m encountering an issue after migrating my VB.NET Windows Forms application from unmanaged ODP.NET to managed ODP.NET, and I’d appreciate your guidance.


Background

  • Application type: VB.NET Windows Forms (.NET Framework)

Earlier setup:

Platform: x86 (32-bit)

  Provider: **Oracle.DataAccess.dll (unmanaged ODP.NET)**

  
     Required Oracle Client installed on client machines

     
     Current setup:

     
        Platform: **x64 (64-bit)**

        
           Provider: **Oracle.ManagedDataAccess.dll (NuGet – managed driver)**

           
              No Oracle Client dependency expected
```---
### Issue Description

On machines **without Oracle Client**, the application works fine.

On machines with **Oracle Client 64-bit (19c)** installed:

   The application **crashes on startup**
   
```sql
  The issue appears related to **duplicate configuration entries** in the `.exe.config`
```---
### Relevant Config Entries

Below are examples of the entries present in my `.exe.config`:

**1. DbProviderFactories section:**


```xml
<system.data>
  <DbProviderFactories>
    <remove invariant="oracle.manageddataaccess.client" />
    <add name="ODP.NET, Managed Driver"
         invariant="oracle.manageddataaccess.client"
         description="..."
         type="..." />
  </DbProviderFactories>
</system.data>

2. Config section declaration:

<section name="oracle.manageddataaccess.client"
         type="OracleInternal.Common.ODPMSectionHandler,
               Version=4.122.23.1,
               Culture=neutral,
               PublicKeyToken=..." />


Key Observation

When I remove the Oracle-related entries from .exe.config, the application starts successfully.

This suggests a conflict between application-level config (from NuGet) and machine-level config (likely added by Oracle Client installation, e.g., machine.config or GAC).


Questions

Why does installing Oracle Client (19c) lead to duplicate configuration behavior for Oracle.ManagedDataAccess?

Does the Oracle Client installer register entries in machine.config that conflict with application config?

What is the recommended approach to avoid this issue?

Should I remove these sections from my .exe.config?

  Or keep only certain entries?

  
     Is there a way to safely override machine-level configuration?

     
     What is the **best practice for deploying a managed ODP.NET application** on systems that may already have Oracle Client installed?
```---
### Goal

I want my **x64 application using Oracle.ManagedDataAccess** to:

Run independently of Oracle Client

Work reliably on machines **with or without Oracle Client installed**

---
Any help or best practices would be greatly appreciated.

Thanks in advance!
Developer technologies | .NET | .NET Runtime
0 comments No comments

Answer accepted by question author

  1. Taki Ly (WICLOUD CORPORATION) 1,020 Reputation points Microsoft External Staff Moderator
    2026-05-04T06:19:01.5733333+00:00

    Hello @Aman Agrahari ,

    This might be happening because when Oracle Client 19c is installed, its installer appears to automatically configure machine-wide settings and the GAC. Because the .NET Framework generally loads machine.config first and checks the GAC before local assemblies, defining the oracle.manageddataaccess.client section again in your .exe.config likely triggers a duplicate section exception, causing the crash.

    I would suggest some approaches to help your application run reliably regardless of the host machine's Oracle Client status:

    1. Remove the <section> declaration: Try deleting <section name="oracle.manageddataaccess.client"...> from your .exe.config entirely. Since the .NET Framework requires section names to be unique across the configuration hierarchy, removing it can help prevent the duplication error.
    2. Keep the <DbProviderFactories> tags: What you did here aligns with Microsoft's design. Using the <remove invariant="..." /> tag is the standard Microsoft .NET mechanism for clearing inherited collection settings to safely override machine-level configurations.
    3. Configure via code: If you rely on specific Oracle settings (like TNS_ADMIN), you might consider setting them programmatically using the OracleConfiguration class at application startup. Oracle provides this class specifically to handle settings in code, which can help decouple your app from XML files and any existing machine-level setups.

    Disclaimer: Some links are non-Microsoft website. The pages appear to be providing accurate, safe information. Watch out for ads on the site that may advertise products frequently classifies as a PUP (Potentially Unwanted Products). Thoroughly research any product advertised on the site before you decide to download and install it.

    I hope this helps with your question. If you found my response helpful, please follow this guide to provide feedback.

    Thank you.

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Senthil kumar 110 Reputation points
    2026-05-01T15:00:05.61+00:00

    Hi Aman Agrahari,

    Please confirm your Visual studio version.

    • Go to project properties then go to compile
    • go to Target CPU select 'Any CPU' and tick Prefer 32 bit.
    • then try to run your application.

    vs

    Thanks


  2. Q&A Assist
    2026-05-01T13:41:42.42+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    The crash is consistent with a duplicate or conflicting DbProviderFactories / config section registration, similar to other scenarios where duplicate provider entries in machine.config or app config cause runtime failures.

    From the context:

    • .NET data providers are registered via DbProviderFactories entries in configuration files (machine.config and application .config).
    • A duplicate DbProviderFactories entry in machine.config is known to cause services to fail and must be removed to restore normal behavior.

    In this case, Oracle Client 19c likely adds its own oracle.manageddataaccess.client registration at the machine level, while the NuGet-based managed driver adds the same registration at the application level, resulting in conflicting or duplicate entries.

    To align with the documented guidance on duplicate provider entries:

    1. Check for duplicate provider entries
      • Inspect machine.config in the .NET Framework folder (for example, C:\Windows\Microsoft.Net\Framework64\v4.0.30319\Config\) and look for DbProviderFactories entries related to oracle.manageddataaccess.client.
      • If there are multiple entries for the same invariant name, remove the duplicate entry, keeping only one consistent definition.
      • Always back up machine.config before editing.
    2. Avoid redundant registrations
      • If Oracle Client 19c already registers oracle.manageddataaccess.client in machine.config, the application-level <system.data><DbProviderFactories> entry for the same invariant can be removed to avoid duplication.
      • Keep only the configuration that is necessary for the application to run. If the managed driver works without any explicit DbProviderFactories entry in .exe.config on machines without Oracle Client, then the app-level registration is not strictly required.
    3. Keep configuration consistent
      • Ensure that the section declaration for oracle.manageddataaccess.client appears only once in the effective configuration hierarchy (machine + app). Multiple declarations for the same section name with different types or versions can cause initialization failures.
      • If the Oracle Client installer has already added the section at machine level, remove the duplicate section declaration from .exe.config.
    4. Best practice for deployment
      • For a managed ODP.NET application that should run with or without Oracle Client installed, rely on a single, consistent registration of oracle.manageddataaccess.client:
        • Prefer application-local configuration (in .exe.config) when full control over the runtime environment is required, and remove conflicting machine-level entries if they cause issues.
        • Alternatively, if machine-level configuration is mandated by the environment, remove the redundant app-level entries and test the application with only the machine-level registration.
      • Before changing machine.config, create a backup and validate changes in a test environment, as incorrect edits can affect all .NET applications on the machine.

    In summary, the crash is caused by duplicate or conflicting oracle.manageddataaccess.client registrations between .exe.config and machine.config. The recommended approach is to remove the duplicate DbProviderFactories and section entries so that only one consistent registration remains, either at the machine level or at the application level, and then test the application on machines with and without Oracle Client installed.


    References:

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.