How to establish data connection between HOLOLENS2 and MYSQL?

啸天 夏 0 Reputation points
2023-03-31T09:06:24.48+00:00

I compiled a program using UNITY to communicate with a MySQL database and retrieve data. When I ran the program in the UNITY editor, I was able to establish a connection to the database. However, when I published the program to HOLOLENS2 and ran it, there were no error messages, but communication was not established. In the program log of HOLOLENS, I found the following error. Can you tell me what the problem is and how to solve it?


NotSupportedException: System.Configuration.ConfigurationManager::GetSection
  at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00000] in <00000000000000000000000000000000>:0 
  at MySql.Data.MySqlClient.MySqlConfiguration..cctor () [0x00000] in <00000000000000000000000000000000>:0 
  at MySql.Data.MySqlClient.Replication.ReplicationManager..cctor () [0x00000] in <00000000000000000000000000000000>:0 
  at MySql.Data.MySqlClient.MySqlConnection.Open () [0x00000] in <00000000000000000000000000000000>:0 
  at lunxun.Start () [0x00000] in <00000000000000000000000000000000>:0 
Rethrow as TypeInitializationException: The type initializer for 'MySql.Data.MySqlClient.MySqlConfiguration' threw an exception.
  at MySql.Data.MySqlClient.Replication.ReplicationManager..cctor () [0x00000] in <00000000000000000000000000000000>:0 
  at MySql.Data.MySqlClient.MySqlConnection.Open () [0x00000] in <00000000000000000000000000000000>:0 
  at lunxun.Start () [0x00000] in <00000000000000000000000000000000>:0 
Rethrow as TypeInitializationException: The type initializer for 'MySql.Data.MySqlClient.Replication.ReplicationManager' threw an exception.
  at MySql.Data.MySqlClient.MySqlConnection.Open () [0x00000] in <00000000000000000000000000000000>:0 
  at lunxun.Start () [0x00000] in <00000000000000000000000000000000>:0 

Exception: 连接失败!The type initializer for 'MySql.Data.MySqlClient.Replication.ReplicationManager' threw an exception.
  at sql.SqlAccess..ctor (System.String host, System.String port, System.String username, System.String pwd, System.String database) [0x00000] in <00000000000000000000000000000000>:0 
  at lunxun.online1 () [0x00000] in <00000000000000000000000000000000>:0 
HoloLens | Development
{count} votes

1 answer

Sort by: Most helpful
  1. clcheles 271 Reputation points Moderator
    2023-04-12T14:09:25.1133333+00:00

    This doesn't seem to be related to Hololens. The ConfigurationManager class is not supported by Unity's IL2CPP scripting backend. You can read here about System.Configuration.ConfigurationManager. This is because ConfigurationManager relies on the System.Configuration namespace, which is not included in the subset of the .NET Framework that's supported by IL2CPP.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.