Bonzo1988
Bonzo1988

Reputation: 11

Npgsqlconnection not defined

I am attempting to establish a remote connection to a PostgreSQL database utilising the Npgsql drivers to create an ADO.NET connection within Visual Basic script component of SQL Server Integration Services. I have:

  1. Set the Target framework to '.NET Framework 4'
  2. Added a reference to Npgsql.dll
  3. Coded 'Imports Npgsql'
  4. Declare variables:
Dim PostgreSQLConnMgr As IDTSConnectionManager100
Dim PostgreSQLConn As NpgsqlConnection
Dim PostgreSQLCmd As NpgsqlCommand
Dim PostgreSQLReader As NpgsqlDataReader

When I build the project I get the following errors which reference the variable declarations:

Type 'NpgsqlConnection' is not defined.
Type 'NpgsqlCommand' is not defined.
Type 'NpgsqlDataReader' is not defined.

In addition warnings were generated including:

The primary reference "Npgsql, Version=4.0.1.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the framework assembly "System.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "Npgsql, Version=4.0.1.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7, processorArchitecture=MSIL" or retarget your application to a framework version which contains "System.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".

I suspect this warning indicates the underlying cause of the errors because Our current framework is version 4.0.30319.

I would appreciate any assistance with this. Thanks in advance

Upvotes: 1

Views: 1050

Answers (1)

Shay Rojansky
Shay Rojansky

Reputation: 16722

As can be seen on its nuget page, Npgsql doesn't support .NET Framework 4. The minimum version of .NET Framework supported is 4.5, in addition to .NET Standard 2.0.

Upvotes: 1

Related Questions