Could not load file or assembly 'System.Text.Encoding.CodePages, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
Tajick
Posts: 2
Joined: Fri 28 May 2021 21:53

Could not load file or assembly 'System.Text.Encoding.CodePages, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f

Post by Tajick » Fri 28 May 2021 21:59

This project has been developed for .NET framework 4.6.1.
Now we have to update it to target 4.7.2 but we are facing a runtime error.
When we create a new PgSqlConnection from a PgSqlConnectionStringBuilder.ConnectionString, it throws:

Code: Select all

System.TypeInitializationException
  HResult=0x80131534
  Message=The type initializer for '  ' threw an exception.
  Source=Devart.Data.PostgreSql
  StackTrace:
   at Devart.Data.PostgreSql.PgSqlConnection..ctor()
   at Devart.Data.PostgreSql.PgSqlConnection..ctor(String connectionString)
   at HttpingUnitTests.UnitTestPersistencyPostgreSql..ctor() in C:\Projects\PostgreSql.cs:line 41

Inner Exception 1:
FileNotFoundException: 
Could not load file or assembly 'System.Text.Encoding.CodePages, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. 
The system cannot find the file specified.
We googled and found this error with reference to AngleShapr but nothing with reference to Devart Postgress driver.
We do not use AngleSharp.
We tried to downgrade from the lastest 7.20.1866 all the way back.
We tried to install all kinds of versions of System.Text.Encoding.CodePages, but first of all there is no version 4.1.1 available from Microsoft, and all other versions did not work.
We tried to add a reference to the whichever System.Text.Encoding.CodePages is installed with Devart Postgresql, to no avail.
Any ideas what is missing and why Devart package does not work when the project targets framework 4.7.1?

Thanks,

Tajick
Posts: 2
Joined: Fri 28 May 2021 21:53

Re: Could not load file or assembly 'System.Text.Encoding.CodePages, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b0

Post by Tajick » Sun 30 May 2021 17:40

I dug deeper into this issue and found that the project worked fine while it had Devart.Data.PostgreSql 7.7.832 nuget package installed. When I go to the package manager, I do not see versions older than 7.9.912.
Please let me know how I can install 7.7.832.
Thanks.

Shalex
Site Admin
Posts: 9306
Joined: Thu 14 Aug 2008 12:44

Re: Could not load file or assembly 'System.Text.Encoding.CodePages, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b0

Post by Shalex » Mon 31 May 2021 15:59

The current implementation of dotConnect for PostgreSQL includes two sets of assemblies:

1) the .NET Framework Devart.* assemblies which are shipped with installation:
* assemblies are created in C:\Program Files (x86)\Devart\dotConnect\PostgreSQL\ , GAC 2.0 (C:\Windows\assembly\GAC_MSIL\), GAC 4.0 (C:\Windows\Microsoft.NET\assembly\GAC_MSIL\)
* licensing approach is described at https://www.devart.com/dotconnect/postg ... nsing.html

2) the .NET Standard (.NET Core) Devart.* assemblies which are available via NuGet:
* you can download packages from https://www.nuget.org/packages/devart.data.postgresql
* licensing approach is described at https://www.devart.com/dotconnect/postg ... ndard.html
Tajick wrote:This project has been developed for .NET framework 4.6.1.
Now we have to update it to target 4.7.2 but we are facing a runtime error.
Please download the provider installation from your Devart Account and use its assemblies with .NET Framework projects.

Post Reply