PostgreSQL FileLoadException

Posts   
 
    
ztron
User
Posts: 13
Joined: 30-Mar-2012
# Posted on: 29-Aug-2022 02:55:03   

When trying to 'Add Relational Model from Database...' , select 'PostgreSql Driver (Npgsql)' driver, supply the details and click 'Next', i get the this exception.

Exception message:
-------------------------------
Exception type: FileLoadException
Could not load file or assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

LLBLGen Pro version 5.9. Build 5.9.0
-----[Core exception]--------------------
   at Npgsql.NpgsqlConnection.<>c__DisplayClass32_0.<Open>g__OpenLong|0()
   at Npgsql.NpgsqlConnection.Open(Boolean async, CancellationToken cancellationToken)
   at Npgsql.NpgsqlConnection.Open()
   at SD.LLBLGen.Pro.Gui.Controls.WizardPages.MetaDataRetrievalWizard_Step_ConnectionData.TestConnectionData(Boolean showSuccess)

Any ideas?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 29-Aug-2022 09:37:43   

You have by any chance a Npgsql version installed in the GAC (so installed with an installer), or have you overwritten the npgsql dll we ship in the drivers folder? You use a normal installation on a windows machine, not a remote setup somewhere?

Frans Bouma | Lead developer LLBLGen Pro
ztron
User
Posts: 13
Joined: 30-Mar-2012
# Posted on: 29-Aug-2022 10:47:38   

no,

it happens on a clean machine with only LLBLGen installed.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 29-Aug-2022 10:54:50   

Reproduced. On our test system we had an npgsql in the gac so it wasn't using the npgsql in the driver folder. We'll look into how to make .NET use the assemblies in the driver folder, as the dll is there.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 29-Aug-2022 10:59:17   

Ah, the dll in the driver folder is a newer version (4.2.0.1, instead of 4.2.0.0) and as we load the driver assembly dynamically auto-assembly redirects aren't happening rage

Please open llblgenpro.exe.config in notepad and at line 118, add:

            <dependentAssembly>
                <assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
            </dependentAssembly>

Then restart the designer. That should fix it. We'll fix it in the official release of course

Frans Bouma | Lead developer LLBLGen Pro
ztron
User
Posts: 13
Joined: 30-Mar-2012
# Posted on: 29-Aug-2022 11:11:42   

that works, thanks simple_smile

Jamanga
User
Posts: 93
Joined: 21-Jul-2006
# Posted on: 08-Sep-2022 12:12:15   

Hi guys

Just started with postgres and LLBLGen 5.9.2 - all was going well really until I hit this issue after creating my db, but that redirect worked - thanks! Before this I did install the dlls to the GAC within Drivers\PostgreSql.

Will I need to put a similar redirect within my web.config?

Initially I started looking at the npgsql drivers on github, but each one I pulled down didn't compile due to .NET dependencies (I was trying to compile on Frameworks 4.8.1)

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 08-Sep-2022 18:41:01   

The designer was depending on an earlier version than the one used to be shipped and deployed in the driver version, that's why a redirect to instruct the designer to use the newer version was needed.

But as you are building your application, you can make sure your code is using the version that's shipped, or which is available at the production site. Otherwise, a redirect is needed at deployment time to fix the issue, instead of re-building the app.

Jamanga
User
Posts: 93
Joined: 21-Jul-2006
# Posted on: 09-Sep-2022 09:07:16   

Hi Walaa

Thanks. All good. In my tester app I installed the postgres assembly via package console against .NET Framework 4.8: Install-Package Npgsql

I then ran into:

ORMGeneralOperationException: None of the factories in the list of 'Npgsql' were found. Please check machine.config and the .NET version your application is running on.

So used the redirect in app.config

<system.data> <DbProviderFactories> <add name="PostgreSql Client Data Provider" invariant="Npgsql" description=".Net Framework Data Provider for PostgreSql" type="Npgsql.NpgsqlFactory, Npgsql, Version=6.0.6.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" /> </DbProviderFactories> </system.data>

.. with the gotcha that the .config file didn't get regenerated in my debug folder after compile, which confused me for a bit. Classic Visual Studio. simple_smile