2016-04-21 87 views
0

我在CentOS 7.1MissingMethodException與+ Npgsql的CLI DOTNET在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不兼容。

必須有一些我做錯了,因爲其他人似乎沒有問題,這更多。

任何想法?

回答

0

我已經與版本Npgsql的同一異常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)'.

但是我可以用兩個版本的成功:3.1.0-unstable04583.1.0 -unstable0478
當前我正在使用Centos 7.2,Dotnet CLI版本1.0.0-rc2-002510。作爲一個測試應用程序,我創建了一個簡單的控制檯應用程序,其中一個select到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連接到數據庫,我不得不幾個選項添加到我的連接字符串:SSL模式=要求;信任服務器證書= TRUE;使用SSL Stream = True

也許你應該嘗試使用更新版本的dotnet cli。如果您對我的os/dotnet環境有任何疑問,請告訴我。