之前网上搜,使用MySQL.Data
在unity编辑器里面运行一切都正常。但是打包程exe就报了以下错误
System.TypeInitializationException
The type initializer for 'MySql.Data.MySqlClient.Replication.ReplicationManager' threw an exception.
at MySql.Data.MySqlClient.MySqlConnection.OpenAsync (System.Boolean execAsync, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at MySql.Data.MySqlClient.MySqlConnection.OpenAsync (System.Boolean execAsync, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0
at MySql.Data.MySqlClient.MySqlConnection.Open () [0x00000] in <00000000000000000000000000000000>:0
at SQLUtil.ExecuteReader (System.String sqlString, System.String connstr) [0x00014] in D:\workspace\svn\unity\IFCViewer\Assets\Scripts\SQLUtil.cs:52
at SQLUtil.SearchDB (System.String ip, System.String port, System.String dBName, System.String userName, System.String password, System.String sqlMsg) [0x00056] in D:\workspace\svn\unity\IFCViewer\Assets\Scripts\SQLUtil.cs:15
at ManageSQLData.GetMsg (System.String[] config, System.String sqlCmd) [0x00011] in D:\workspace\svn\unity\IFCViewer\Assets\Scripts\ManageSQLData.cs:61
at ManageSQLData.getMsg (System.String sqlCmd) [0x00008] in D:\workspace\svn\unity\IFCViewer\Assets\Scripts\ManageSQLData.cs:65
at ManageSQLData.initFromDB (System.String tableName) [0x00030] in D:\workspace\svn\unity\IFCViewer\Assets\Scripts\ManageSQLData.cs:73
at ManageSQLData.Awake () [0x0000d] in D:\workspace\svn\unity\IFCViewer\Assets\Scripts\ManageSQLData.cs:57
--- End of stack trace from previous location where exception was thrown ---
网上搜了一遍,最后发现直接把MySQL.Data换掉,换成MySQLConnector就行了。下载NuGet插件用之前一篇日志中的插件NuGetForUnity。
打包以后可以正常链接数据库了
暂无关于此日志的评论。