尝试连接MySQL数据库时,Mono抛出异常

时间:2016-06-21 14:31:02

标签: c# mysql .net mono

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

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

2 个答案:

答案 0 :(得分:1)

  

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

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

答案 1 :(得分:0)

向MySQL报告了这个错误。链接:https://bugs.mysql.com/bug.php?id=81973