I am getting System.InvalidProgramException error when upgraded the application from .NET 3.0 to .NET 8.0

Singh, Sheetal 0 Reputation points
2024-05-13T07:12:21.36+00:00

I have upgraded Npgsql package from version 4.1.5 to version 8.0.2 that is required for .NET 8 upgradation but I am getting the following error after deployment of the service on the development environment and performing the health check for it:

"name": "database_connectivitycheck",
      "status": "Unhealthy",
      "message": "Failed to access database. Database type: PushNotificationService.DataAccess.Database.DataAccessPostgresDatabase - System.InvalidProgramException: Common Language Runtime detected an invalid program.\n   at Npgsql.NpgsqlCommand.ExecuteReaderAsync(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)\n   at Npgsql.NpgsqlCommand.ExecuteReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)\n   at Npgsql.NpgsqlCommand.ExecuteReaderAsync(CancellationToken cancellationToken)\n   at Npgsql.PostgresDatabaseInfo.LoadBackendTypes(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async)\n   at Npgsql.PostgresDatabaseInfo.LoadPostgresInfo(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async)\n   at Npgsql.PostgresDatabaseInfoFactory.Load(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async)\n   at Npgsql.NpgsqlDatabaseInfo.Load(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async)\n   at Npgsql.NpgsqlConnector.LoadDatabaseInfo(NpgsqlTimeout timeout, Boolean async)\n   at Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)\n   at Npgsql.ConnectorPool.AllocateLong(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)\n   at Npgsql.NpgsqlConnection.<>c__DisplayClass32_0.<<Open>g__OpenLong|0>d.MoveNext()\n--- End of stack trace from previous location ---\n   at PushNotificationService.DataAccess.Database.DataAccessPostgresDatabase.Transaction.StartAsync(String connectionString) in /builds/respiratory/ispiro/pushnotificationservice/PushNotificationService/DataAccess/Database/DataAccessPostgresDatabase.cs:line 155\n   at PushNotificationService.DataAccess.Database.DataAccessPostgresDatabase.StartTransactionAsync() in /builds/respiratory/ispiro/pushnotificationservice/PushNotificationService/DataAccess/Database/DataAccessPostgresDatabase.cs:line 25\n   at PushNotificationService.DataAccess.DataAccessService.CheckHealth() in /builds/respiratory/ispiro/pushnotificationservice/PushNotificationService/DataAccess/DataAccessService.cs:line 132\n   at PushNotificationService.Configuration.HealthCheckExtensions.CheckDatabase(IDataAccessService db) in /builds/respiratory/ispiro/pushnotificationservice/PushNotificationService/Configuration/HealthCheckExtensions.cs:line 75"
    },
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,918 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,611 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,166 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.