错误从UWP应用程序连接到Postgres数据库

错误从UWP应用程序连接到Postgres数据库

问题描述:

试图使用Npgsql的,并得到一个错误加载以下组件从UWP应用程序连接到一个Postgres数据库:错误从UWP应用程序连接到Postgres数据库

"System.Net.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 

这是确切的例外:

{System.IO.FileNotFoundException: Could not load file or assembly 'System.Net.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. 
File name: 'System.Net.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 
    at Npgsql.NpgsqlConnector.<RawOpen>d__139.MoveNext() 
    at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine) 
    at Npgsql.NpgsqlConnector.RawOpen(NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken) 
    at Npgsql.NpgsqlConnector.<Open>d__136.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) 
    at Npgsql.ConnectorPool.<AllocateLong>d__24.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Runtime.CompilerServices.ValueTaskAwaiter`1.GetResult() 
    at Npgsql.NpgsqlConnection.<Open>d__24.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Npgsql.NpgsqlConnection.Open() 
    at ... >>> here goes my code 

这是一个已知问题,请参阅https://github.com/npgsql/npgsql/issues/820

不幸的是,你将有几个月的时间,直到UWP支持netstandard20,在这一点上,这将消失。

+0

现在会尝试使用标准2.0预览工作吗? – Bishoy