如何通过asp.net连接到postgresql数据库 [英] how to connect to postgresql database through asp.net

查看:683
本文介绍了如何通过asp.net连接到postgresql数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过asp.net连接到postgresql数据库,但即使在正确编写代码后也会反复出现此错误。任何人都可以帮我解决这里的解决方案是我的代码? : -



Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles Button1.Click

Dim con作为NpgsqlConnection

con =新的NpgsqlConnection(server = localhost; port = 5432; userid = mayank; password = manager; database = postgres)

con.Open()

MsgBox(已打开)



结束次级



错误我得到的是: -



无法加载文件或程序集'Mono.Security,Version = 1.0.5000.0,Culture = neutral,PublicKeyToken = 0738eb9f132ed756'或其中一个它的依赖关系。定位的程序集的清单定义与程序集引用不匹配。 (来自HRESULT的异常:0x80131040)



我已添加monosecurity.dll作为参考但尚未连接到postgresql db ... m使用npgsql驱动程序连接到postgresql数据库

I am trying to connect to postgresql databse through asp.net but getting this error again and again even after writing code correctly. Can anyone please help me out with the solution here is my code? :-

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim con As NpgsqlConnection
con = New NpgsqlConnection("server=localhost;port=5432;userid=mayank;password=manager;database=postgres")
con.Open()
MsgBox("opened")

End Sub

Error that i am getting is :-

Could not load file or assembly 'Mono.Security, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I have added monosecurity.dll as refernce yet not getting connected to postgresql db...m using npgsql driver to connect to postgresql database

推荐答案

您必须使用您下载的Novell.Directory.Ldap.dll附带的Mono.Security.dll文件,否则您将遇到二进制兼容性问题。



请注意,Mono.Security.dll的版本号与框架版本匹配,因为此程序集是Mono框架的一部分,其中大部分安全性都使用它工具。因此,你不能四处寻找文件(你可能很幸运,但不要指望它)你需要用于测试Novell.Directory.Ldap.dll的文件。
You must use the Mono.Security.dll file that comes with the Novell.Directory.Ldap.dll you downloaded, otherwise you;ll run into binary compatibility issue.

Note that the version number of Mono.Security.dll match the framework version since this assembly is part of the Mono framework where it is used by most of its security tools. As such you cannot go around and look for the file (well you could be lucky, but don't count on it) you need the one that was used to test Novell.Directory.Ldap.dll.


这篇关于如何通过asp.net连接到postgresql数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆