【问题标题】:MissingMethodException on connect with Npgsql + Dotnet CLI on CentOs 7.1在 CentOs 7.1 上与 Npgsql + Dotnet CLI 连接时出现 MissingMethodException
【发布时间】:2016-08-14 23:05:03
【问题描述】:

我在 CentOS 7.1 上运行 Dotnet CLI 版本 1.0.0-rc2-002439

我已经构建了一个原型控制台应用程序,它只对 PostgreSQL 9.4 数据库执行选择。

我只针对 DNXCORE50,在 Windows 上,一切正常。当我在 CentOS 上运行它时,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)

这是我正在使用的 project.json:

{
  "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"
      }
    }
  }
}

我在 npgsql 的 Github 上看到使用 https://www.myget.org/gallery/npgsql-unstable 作为包源并使用 Npgsql 的不稳定版本修复它但是当我使用 "Npgsql": "3.1.0-unstable0458" 时应用程序无法编译并说这个版本的 npgsql 不是兼容 DNXCore 5.0。

一定是我做错了什么,因为其他人似乎不再对此有任何问题。

有什么想法吗?

【问题讨论】:

    标签: postgresql npgsql dnx50 dotnet-cli


    【解决方案1】:

    npgsql 版本 3.1.0-alpha6 我也遇到了同样的异常

    未处理的异常:System.MissingMethodException:找不到方法:'无效 System.Net.Security.SslStream.AuthenticateAsClient(System.String, System.Security.Cryptography.X509Certificates.X509CertificateCollection, System.Security.Authentication.SslProtocols, Boolean) '。

    但是,我能够成功使用两个版本:3.1.0-unstable04583.1.0-unstable0478
    目前我使用的是 Centos 7.2,Dotnet CLI 版本 1.0.0-rc2-002510。作为一个测试应用程序,我创建了一个简单的控制台应用程序,其中包含一个对 postgresql 的选择。
    project.json 看起来像这样:

    {
      "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",
        }
      }
    }
    

    因为我使用 SSL 连接到 db,所以我必须在我的连接字符串中添加几个选项:SSL Mode=Require;Trust Server Certificate=True;Use SSL Stream=True

    也许您应该尝试使用较新版本的 dotnet cli。如果您对我的 os/dotnet 环境有任何疑问,请告诉我。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-06
      • 1970-01-01
      • 2016-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多