0

So I am connecting to PostgreSQL using Npgsql library but getting error when I try to connect to Production environment although the same code works for Dev environment. Even the version of PostgreSQL is exactly the same on Prod and Dev but it doesn't work. Trying for more than 2 hours now and saw various threads here on Stackoverflow and other sites but no luck.

PostgreSQL version
PostgreSQL 13.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.4.1 20200928 (Red Hat 8.4.1-1), 64-bit

.Net version 4.7.1 (it's a command line application)

Npgsql.dll version 2.2.3.0

Error
Only AuthenticationClearTextPassword and AuthenticationMD5Password supported for now. Received: 10

If I use Npgsql.dll 4.0.4.0 then I start getting following error for both Prod and Dev environment.

Error
Could not load file or assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies

Unable to solve this issue please help.

Frank Martin
  • 3,147
  • 16
  • 52
  • 73
  • This error virtually always means you need to manually review your dependent references and find version conflicts. Do note the problem could be a shared dependency that 2 or more libraries you reference depends upon, or even further down the dependency tree from `System.Threading.Tasks.Extensions`. And you may need to check every library that ends up in your bin folder. – NightOwl888 May 23 '22 at 12:55
  • Ok I fixed it by creating a new test console application. Then referencing correct DLLs and adding their dependency in config file. But now when I do the same change in my original application, I am getting error `The type initializer for 'Npgsql.PoolManager' threw an exception` – Frank Martin May 23 '22 at 13:00
  • I put that exception message into Google, and this is the first hit: https://stackoverflow.com/questions/53261499/the-type-initializer-for-npgsql-poolmanager-threw-an-exception – NightOwl888 May 23 '22 at 13:20
  • Yeah I already got that. Added `System.ValueTuple.dll` and now everything works fine. – Frank Martin May 24 '22 at 07:09

0 Answers0