本文介绍了在c#中连接到PostgreSQL时出现AccessViolationException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有PostgreSQL 9.5和Visual Studio 2010;
我正在尝试通过C#应用程序连接到数据库;下面是代码
I have PostgreSQL 9.5 and Visual studio 2010;
I'm trying to connect to database through C# application; below is the code
string connstring = "Server=127.0.0.1;Port=5432;User Id=[UserID];Password=[UserPassword];Database=[Database];";
NpgsqlConnection conn = new NpgsqlConnection(connstring);
conn.Open();
我引用了 Npgsql
我的代码中有 Mono.Security
。
以下是我收到的错误消息:
I have referenced Npgsql
and Mono.Security
in my code.
Below is the error message I received:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
和stacktrace是/ b $ b
and stacktrace is
at Npgsql.NpgsqlEventLog.LogMsg(ResourceManager resman, String ResourceString, LogLevel msglevel, Object[] Parameters)
at Npgsql.NpgsqlClosedState.Open(NpgsqlConnector context, Int32 timeout)
at Npgsql.NpgsqlConnector.Open()
at Npgsql.NpgsqlConnectorPool.GetPooledConnector(NpgsqlConnection Connection)
at Npgsql.NpgsqlConnectorPool.RequestPooledConnectorInternal(NpgsqlConnection Connection)
at Npgsql.NpgsqlConnectorPool.RequestConnector(NpgsqlConnection Connection)
at Npgsql.NpgsqlConnection.Open()
at PostGreSQLTest.Form1.button1_Click(Object sender, EventArgs e) in E:\TRIALS GD\PostGreSQLTest\PostGreSQLTest\Form1.cs:line 35
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at PostGreSQLTest.Program.Main() in E:\TRIALS GD\PostGreSQLTest\PostGreSQLTest\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
推荐答案
这篇关于在c#中连接到PostgreSQL时出现AccessViolationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!