尝试连接到 MySQL 数据库时 Mono 抛出异常 [英] Mono throws Exception when trying to connect to MySQL-database

查看:92
本文介绍了尝试连接到 MySQL 数据库时 Mono 抛出异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的应用程序 (.NET 4.5.2),它使用 MySQL 驱动程序 (v6.9.8) for .NET/Mono.它在 .NET (Windows) 上运行良好,但在 Ubuntu (Mono v4.2.1) 上只要我调用 Connect 方法就会抛出异常.

I have a simple application (.NET 4.5.2) which makes usage of the MySQL-driver (v6.9.8) for .NET/Mono. It works perfectly on .NET (Windows) but throws an exception on Ubuntu (Mono v4.2.1) as soon as I invoke the Connect-method.

2016-06-21 16:21:19,659 [1] WARN  MySql.DatabaseDriverMySql [(null)] - System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
File name: 'System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
  at System.Reflection.MonoProperty.GetterAdapterFrame[T,R] (System.Reflection.Getter`2 getter, System.Object obj) <0x7f65f01aece0 + 0x00039> in <filename unknown>:0
  at System.Reflection.MonoProperty.GetValue (System.Object obj, System.Object[] index) <0x7f65f01aef20 + 0x000d9> in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Reflection.MonoProperty.GetValue (System.Object obj, System.Object[] index) <0x7f65f01aef20 + 0x00117> in <filename unknown>:0
  at MySql.Data.MySqlClient.NativeDriver.SetConnectAttrs () <0x40e6a2f0 + 0x00138> in <filename unknown>:0
  at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.Authenticate (Boolean reset) <0x40e69830 + 0x0016b> in <filename unknown>:0
  at MySql.Data.MySqlClient.NativeDriver.Authenticate (System.String authMethod, Boolean reset) <0x40e68320 + 0x000af> in <filename unknown>:0
  at MySql.Data.MySqlClient.NativeDriver.Open () <0x40e5c9d0 + 0x00787> in <filename unknown>:0
  at MySql.Data.MySqlClient.Driver.Open () <0x40e5c980 + 0x0003b> in <filename unknown>:0
  at MySql.Data.MySqlClient.Driver.Create (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings) <0x40e56be0 + 0x00173> in <filename unknown>:0
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
File name: 'System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
  at System.Reflection.MonoProperty.GetterAdapterFrame[T,R] (System.Reflection.Getter getter, System.Object obj) <0x7f65f01aece0 + 0x00039> in <filename unknown>:0
  at System.Reflection.MonoProperty.GetValue (System.Object obj, System.Object[] index) <0x7f65f01aef20 + 0x000d9> in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Reflection.MonoProperty.GetValue (System.Object obj, System.Object[] index) <0x7f65f01aef20 + 0x00117> in <filename unknown>:0
  at MySql.Data.MySqlClient.NativeDriver.SetConnectAttrs () <0x40e6a2f0 + 0x00138> in <filename unknown>:0
  at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.Authenticate (Boolean reset) <0x40e69830 + 0x0016b> in <filename unknown>:0
  at MySql.Data.MySqlClient.NativeDriver.Authenticate (System.String authMethod, Boolean reset) <0x40e68320 + 0x000af> in <filename unknown>:0
  at MySql.Data.MySqlClient.NativeDriver.Open () <0x40e5c9d0 + 0x00787> in <filename unknown>:0
  at MySql.Data.MySqlClient.Driver.Open () <0x40e5c980 + 0x0003b> in <filename unknown>:0
  at MySql.Data.MySqlClient.Driver.Create (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings) <0x40e56be0 + 0x00173> in <filename unknown>:0

推荐答案

无法加载文件或程序集System.Management, Version=4.0.0.0

Could not load file or assembly 'System.Management, Version=4.0.0.0

System.Management 是一个仅适用于 Windows 的库.如果 MySQL 连接器驱动程序突然开始依赖这个库,那就很糟糕了.IIRC Mysql .NET 连接器一直与 Mono 一起工作,因此我们需要将此问题报告为回归.

System.Management is a library that only works on Windows. If the MySQL connector driver has suddenly started to depend on this library, this is pretty bad. IIRC the Mysql .NET connector has always worked with Mono, so we would need to report this problem as a regression.

这篇关于尝试连接到 MySQL 数据库时 Mono 抛出异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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