Skip to Main Content

ODP.NET Core error on Blazor Client. Does it work with WASM?

F.J.Jun 1 2021

Hi, hopefully someone can confirm or help me solve this.
Steps to Repro:
Create the default Blazor Client project in Visual Studio (I'm using Community 2019 16.10.0)
Add the Oracle.ManagedDataAccess.Core (3.21.1) NuGet package
Modify the Counter.razor file to add the code to open the Database connection. The only change to the auto-generated code is the Using clauses for the ODP and the attempt to create the OracleConnection.

@page "/counter"
@using Oracle.ManagedDataAccess.Client
@using Oracle.ManagedDataAccess.Types
<p>Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
@code {
    private int currentCount = 0;
    private void IncrementCount()
        string conString = "User Id=hr;Password=hr;DAta Source=localhost:1521/orcl;";
         // THE ERROR HAPPENS HERE, with or without the conString as a parameter
         OracleConnection con = new  OracleConnection();

        //con.ConnectionString = conString;

This is the error thrown as shown in the browser console:
crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
    Unhandled exception rendering component: The type initializer for 'OracleInternal.Common.ProviderConfig' threw an exception.
System.TypeInitializationException: The type initializer for 'OracleInternal.Common.ProviderConfig' threw an exception. ---> System.InvalidOperationException: Process has exited or is inaccessible, so the requested information is not available.
 at System.Diagnostics.Process.get_ProcessName () <0x31c4300 + 0x0004a> in <filename unknown>:0
 at OracleInternal.Common.CustomConfigFileReader.GetProcessAndEnvInfo () <0x31c4120 + 0x00022> in <filename unknown>:0
 at OracleInternal.Common.CustomConfigFileReader..ctor (System.Boolean bIsManaged) <0x31c1df8 + 0x00054> in <filename unknown>:0
 at OracleInternal.Common.ConfigBaseClass.GetInstance (System.Boolean bIsManaged) <0x31c1670 + 0x0000e> in <filename unknown>:0
 at OracleInternal.Common.ProviderConfig..cctor () <0x31c1328 + 0x0003a> in <filename unknown>:0
 --- End of inner exception stack trace ---
 at Oracle.ManagedDataAccess.Client.OracleConnection..ctor () <0x319f438 + 0x0008a> in <filename unknown>:0
 at test1.wasm.notcorehosted._31.Pages.Counter.IncrementCount () <0x3166bd0 + 0x00026> in <filename unknown>:0
 at Microsoft.AspNetCore.Components.EventCallbackWorkItem.InvokeAsync[T] (System.MulticastDelegate delegate, T arg) <0x31460b8 + 0x0005e> in <filename unknown>:0
 at Microsoft.AspNetCore.Components.EventCallbackWorkItem.InvokeAsync (System.Object arg) <0x3145df8 + 0x0000a> in <filename unknown>:0
 at Microsoft.AspNetCore.Components.ComponentBase.Microsoft.AspNetCore.Components.IHandleEvent.HandleEventAsync (Microsoft.AspNetCore.Components.EventCallbackWorkItem callback, System.Object arg) <0x3145d60 + 0x0000a> in <filename unknown>:0
 at Microsoft.AspNetCore.Components.EventCallback.InvokeAsync (System.Object arg) <0x31438f0 + 0x00040> in <filename unknown>:0
 at Microsoft.AspNetCore.Components.RenderTree.Renderer.DispatchEventAsync (System.UInt64 eventHandlerId, Microsoft.AspNetCore.Components.RenderTree.EventFieldInfo fieldInfo, System.EventArgs eventArgs) <0x3142ee0 + 0x000a8> in <filename unknown>:0 blazor.webassembly.js:1:38061


Please note:    The same steps and code work if the Blazor project is a Blazor Server project instead of Client.

Any guidance and help is greatly appreciated.


Post Details
Added on Jun 1 2021