RuntimeConfiguration.ConfigureDQE for AccessDQEConfiguration throwing exception

Posts   
 
    
Posts: 2
Joined: 27-Apr-2021
# Posted on: 27-Apr-2021 08:33:26   

Hi,

I am investigating the feasibility of converting an application written in .Net framework 2 over to .Net 5.

I have a small .Net 5 console app set up and I am trying to get a basic test application running as a POC. The code is as follows:

Sub Main(args As String())
        Console.WriteLine("Hello World!")

        System.Data.Common.DbProviderFactories.RegisterFactory("System.Data.OleDb", System.Data.OleDb.OleDbFactory.Instance)

        RuntimeConfiguration.ConfigureDQE(Of SD.LLBLGen.Pro.DQE.Access.AccessDQEConfiguration)(Sub(x)
                                                                                                   x.AddDbProviderFactory(GetType(System.Data.OleDb.OleDbFactory))
                                                                                               End Sub)

        Dim dt As System.Data.DataTable = System.Data.Common.DbProviderFactories.GetFactoryClasses()
        Console.WriteLine(dt.Rows.Count)
        Console.ReadKey()
    End Sub

The line that calls ConfigureDQE is throwing the following exception:

No DbProviderFactory has been configured for this DQE. You have to use the DQE configuration system to register at least one DbProviderFactory.

I must admit that my knowledge is limited when it comes to OleDb, Ado .Net, DataProviders etc. I am also struggling due to the fact that there are huge differences between the two frameworks with regards to configuration etc.

What I can't understand is why I am getting that particular exception - I am trying to configure the DQE system by calling ConfigureDQE to register a factory. For it to come back and tell me I need to provide a factory at that point seems absurd.

Appreciate any help.

cheers!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 27-Apr-2021 08:40:51   

We'll look into it

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 27-Apr-2021 10:09:08   

At the moment we don't support MS Access on .NET Core/standard/net5+, only on .NET Framework (.net 4.5.x and higher). The main reason for that was that for a long time (on .net core at least) MS didn't release an ado.net provider which worked and as the MS Access driver is COM based and tied to windows it wasn't a big problem.

I see for .NET 5 Microsoft has released an OleDb provider so we can proceed with supporting MS Access on .NET 5+ at least, but the current version doesn't support MS Access on .net 5. You therefore need to fall back to .NET 4.8 if you want MS Access.

We've added a work item to add support for MS Access for .NET 5 / .net standard 2.1 to LLBLGen Pro v5.8.1 but it won't be out today. Not sure if you can fall back to .NET 4.8 (full framework) or that you need to use .net 5 for your project.

(Building the MS Access DQE from source for .net standard 2.1 is straightforward, however the generated code also needs adjustment with a new (small) template to make sure the namespace is included for netstandard).

The main issue you run into is that the code which obtains the factory from the DbProviderFactories table is called from the static constructor of the DQE and this runs before your line of code which registers the factory. The netstandard 2.0 builds don't have that code, as at the time when I contributed the DbProviderFactories registration code to .NET Core (Irony, right? I wrote that RegisterFactory method wink ) MS had stalled the process for so long it missed the window for .netstandard 2.0 definitions and therefore never made it in (it's in netstandard 2.1 but that's useless).

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 27-Apr-2021 11:07:19   

It turned out to be a small job, so we're pushing the 5.8.1 hotfix with MS Access support now, should be available in 10 minutes.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 27-Apr-2021 11:17:40   

Hotfix is now available, with MS Access support for net standard 2.0. To use ms access on .net standard (windows only) you need to generate code for netstandard 2.0 or 2.1, and do the following in your app:

RuntimeConfiguration.AddConnectionString("ConnectionString.MS Access (OleDb)", @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=... path to .accdb;User Id=admin;Password=;Jet OLEDB:System Database=;Jet OLEDB:Database password=");
RuntimeConfiguration.ConfigureDQE<AccessDQEConfiguration>(c => c.AddDbProviderFactory(typeof(System.Data.OleDb.OleDbFactory)));

You have to reference System.Data.OleDb v5.0 from nuget.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 2
Joined: 27-Apr-2021
# Posted on: 28-Apr-2021 03:39:57   

Thank you so much...I've upgraded to the latest hotfix and it now works without issue. I appreciate the fast turnaround time!

cheers!

Mark