简体   繁体   中英

MissingMethodException on connect with Npgsql + Dotnet CLI on CentOs 7.1

I'm running Dotnet CLI version 1.0.0-rc2-002439 on CentOS 7.1

I've built a prototype Console application that just performs a select against a PostgreSQL 9.4 database.

I'm only targeting DNXCORE50 and on windows, everything works just fine. When I'm running it on CentOS I get the following exception on conn.Open()

Unhandled Exception: System.MissingMethodException: Method not found: 'Void  System.Net.Security.SslStream.AuthenticateAsClient(System.String,  System.Security.Cryptography.X509Certificates.X509CertificateCollection,  System.Security.Authentication.SslProtocols, Boolean)'.
at Npgsql.NpgsqlConnector.RawOpen(NpgsqlTimeout timeout)
at Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout)
at Npgsql.NpgsqlConnector.Open()
at Npgsql.NpgsqlConnectorPool.GetPooledConnector(NpgsqlConnection Connection)
at Npgsql.NpgsqlConnectorPool.RequestConnector(NpgsqlConnection connection)
at Npgsql.NpgsqlConnection.OpenInternal(NpgsqlTimeout timeout)
at Npgsql.NpgsqlConnection.Open()
at SensorBot.Core.Services.ConfigService.GetConfig()
at ConsoleApplication.Program.Main(String[] args)

Here is the project.json I'm using :

{
  "version": "1.0.0-*",
  "compilationOptions": {
    "emitEntryPoint": false
  },
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0-rc2-23811"
    },
  },
  "runtimes": { "centos.7-x64": { } },
  "frameworks": {
    "dnxcore50": {
      "dependencies": {
        "Microsoft.CSharp": "4.0.1-beta-23516",
        "System.Collections": "4.0.11-beta-23516",
        "System.Console": "4.0.0-beta-23516",
        "System.Linq": "4.0.1-beta-23516",
        "System.Threading": "4.0.11-beta-23516",
        "System.IO": "4.1.0-*",
        "System.IO.FileSystem": "4.0.1-rc2-23811",
        "System.Runtime.Serialization.Primitives": "4.1.1-*",
        "System.Dynamic.Runtime": "4.0.11-*",
        "System.Net.Security": "4.0.0-beta-23405",
        "System.Net.NetworkInformation": "4.1.0-beta-23405",
        "System.Text.RegularExpressions": "4.0.12-rc2-23811",
        "Npgsql": "3.1.0-alpha6"
      }
    }
  }
}

I have seen on the npgsql's Github that using https://www.myget.org/gallery/npgsql-unstable as a package source and using the unstable version of Npgsql fixes it but when I use "Npgsql": "3.1.0-unstable0458" the app doesn't compile and says that this version of npgsql is not compatible with DNXCore 5.0.

There must be something I'm doing wrong because other people don't seem to have issues with this any more.

Any ideas ?

I've had the same exception with npgsql version 3.1.0-alpha6

Unhandled Exception: System.MissingMethodException: Method not found: 'Void  System.Net.Security.SslStream.AuthenticateAsClient(System.String,  System.Security.Cryptography.X509Certificates.X509CertificateCollection,  System.Security.Authentication.SslProtocols, Boolean)'.

However I was able to succeed with both versions: 3.1.0-unstable0458 and 3.1.0-unstable0478 .
Currently I'm using Centos 7.2 , Dotnet CLI version 1.0.0-rc2-002510 . As a test application I've created a simple console app with one select to postgresql.
project.json looks like this:

{
  "version": "1.0.0-*",
  "compilationOptions": {
    "emitEntryPoint": true
  },
  "dependencies": {
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.0-rc2-23811"
    },
    "Npgsql": "3.1.0-unstable0478"
  },
 "frameworks": {
    "netcoreapp1.0": {
      "imports": "dnxcore50",
    }
  }
}

Because I use SSL connection to db I had to add few options to my connection string: SSL Mode=Require;Trust Server Certificate=True;Use SSL Stream=True .

Maybe you should try to use a newer version of dotnet cli. If you have any questions about my os/dotnet environment, please let me know.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM