Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#MySql连接器/网络问题_C#_Mysql_Connector Net_Idbconnection - Fatal编程技术网

C#MySql连接器/网络问题

C#MySql连接器/网络问题,c#,mysql,connector-net,idbconnection,C#,Mysql,Connector Net,Idbconnection,目前正在运行Mono。我在位于/usr/lib/mono/gac的gac文件夹中加载了MySQL并安装了connector/net。问题是,每次我尝试使用简单的连接测试运行它时,都会出现以下错误: **(/home/holland/code/csharp/test/test/bin/Debug/test.exe:10278):警告**:无法加载从/home/holland/code/csharp/test/test/bin/Debug/test.exe引用的以下程序集: 程序集:MySql.Da

目前正在运行Mono。我在位于/usr/lib/mono/gac的gac文件夹中加载了MySQL并安装了connector/net。问题是,每次我尝试使用简单的连接测试运行它时,都会出现以下错误:

**(/home/holland/code/csharp/test/test/bin/Debug/test.exe:10278):警告**:无法加载从/home/holland/code/csharp/test/test/bin/Debug/test.exe引用的以下程序集:
程序集:MySql.Data(assemblyref_index=1)
版本:6.4.4.0
公钥:c5687fc88969c44d
在全局程序集缓存(MONO_path环境变量中列出的路径)或正在执行的程序集的位置(/home/holland/Code/csharp/test/test/bin/Debug/)中找不到该程序集。
**(/home/holland/Code/csharp/test/test/bin/Debug/test.exe:10278):警告**:无法加载文件或程序集“MySql.Data,Version=6.4.4.0,Culture=neutral,PublicKeyToken=c5687fc88969c44d”或其依赖项之一。
**(/home/holland/Code/csharp/test/test/bin/Debug/test.exe:10278):警告**:程序集/home/holland/Code/csharp/test/test/bin/Debug/test.exe中缺少方法.ctor,键入MySql.Data.MySqlClient.MySqlConnection
**(/home/holland/Code/csharp/test/test/bin/Debug/test.exe:10278):警告**:无法加载文件或程序集“MySql.Data,Version=6.4.4.0,Culture=neutral,PublicKeyToken=c5687fc88969c44d”或其依赖项之一。
**(/home/holland/Code/csharp/test/test/bin/Debug/test.exe:10278):警告**:程序集/home/holland/Code/csharp/test/test/bin/Debug/test.exe中缺少方法.ctor,键入MySql.Data.MySqlClient.MySqlConnection
未处理的异常:System.IO.FileNotFoundException:无法加载文件或程序集“MySql.Data,版本=6.4.4.0,区域性=中性,PublicKeyToken=c5687fc88969c44d”或其依赖项之一。
文件名:“MySql.Data,版本=6.4.4.0,区域性=neutral,PublicKeyToken=c5687fc88969c44d”
在0中的Test.MainClass.Main(System.String[]args)[0x00000]处
如果我没有记错的话,它应该是一个程序集文件

这是我的密码:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using MySql.Data.MySqlClient;

namespace Test
{
    public class Database
    {
        public Database()
        {

        }

        public static IDbConnection MainConnect()
        {
            string connectionInfo = 
            "Server=localhost;"+
            "Database=ecom_main;"+
            "User ID=root;"+
            "Password=xxxxxxx"+
            "Pooling=false;";

            return new MySqlConnection(connectionInfo);
        }

我遇到了同样的问题,我按照以下步骤解决了它:

  • 使dll的副本大小写有效:
  • #cp mysql.data.dll mysql.data.dll
  • 安装连接器 #gacutil -i -package 2.0 MySql.Data.dll #gacutil-i-package 2.0 MySql.Data.dll 这将安装在GAC中,并在/usr/lib/mono/2.0中添加一个符号链接
  • 如果程序集未出现在monodevelop中,则可以将对项目中dll的引用添加到/usr/lib/mono/2.0

  • +信息:

    是否检查该文件夹是否与MONO_路径变量相同?MONO_路径变量在哪里?如何安装程序集?你用过gacutil吗?MONO_PATH是一个环境变量,正如Jon所说,你用gacutil向GAC注册了吗,把它放在文件夹里并不总是有效。更新:我在目录上导出了MONO_PATH,但不幸的是,我什么都找不到。遇到了同样的问题。这足以让它的大小写更有意义(运行Ubuntu)。谢谢,我也一样。将
    mysql.data.dll
    重命名为
    mysql.data.dll
    使mono运行没有任何问题。区分大小写对我也有帮助,可笑的是:p #cp mysql.data.dll MySql.Data.dll #gacutil -i -package 2.0 MySql.Data.dll