title: Having trouble connecting Unity3d WebGL project build to database, works fine in editor
body: <p>I used this code to connect my Unity project to my MySql database:</p>
  
  <pre><code>public void SetupSQLConnection()
  {
      Debug.Log("Connection Function Started");
      if (connection == null)
      {
          Debug.Log("If connection == null");
          try
          {
              Debug.Log("Try block started");
              MySqlConnectionStringBuilder connBuilder = new MySqlConnectionStringBuilder();
  
              connBuilder.Server = "localhost";
              connBuilder.UserID = "root";
              connBuilder.Database = "therapygame";
              connBuilder.Password = "";
              connBuilder.OldGuids = true;
  
              Debug.Log("String set");
              connection = new MySqlConnection(connBuilder.ConnectionString);
              Debug.Log("new MySqlConnection");
              connection.Open();
              Debug.Log("connection");
          }
          catch (MySqlException ex)
          {
              Debug.LogError("MySQL Error: " + ex.ToString());
          }
      }
  }
  </code></pre>
  
  <p>This works fine when running my project in the Unity3d editor. However, when I build the WebGL, it no longer connects to the database.</p>
  
  <p>The error happens between the Debug.Logs of "new MySqlConnection" and "connection". In other words, it is failing at the connection.Open(); statement.</p>
  
  <p>Here is the console log in Google Chrome:</p>
  
  <pre><code>SystemException: Thread creation failed.
  
  Rethrow as TypeInitializationException: The type initializer for 'System.Threading.Timer.Scheduler' threw an exception.
  
  Rethrow as TypeInitializationException: The type initializer for 'System.Threading.Timer' threw an exception.
  
  Rethrow as TypeInitializationException: The type initializer for 'MySql.Data.MySqlClient.MySqlPoolManager' threw an exception.
  
  
  (Filename: currently not available on il2cpp Line: -1)
  </code></pre>
  
  <p>And here is the source of that error (it is so large that I had to break it apart into sections)(see following section to know what to look for):</p>
  
  <p><a href="https://0bin.net/paste/-28c3BvLx+Nx+Q+L#ltyOWWb+IembwSAgNKzPCRwvI5MkPOrUfgOAs3i4R+f" rel="nofollow noreferrer">https://0bin.net/paste/-28c3BvLx+Nx+Q+L#ltyOWWb+IembwSAgNKzPCRwvI5MkPOrUfgOAs3i4R+f</a></p>
  
  <p><a href="https://0bin.net/paste/ZleyLDeOcgr3kj-e#OPVr3oIC8-mcO9mXB1pV/+ONcdnUB+3I1RCy37/NI+p" rel="nofollow noreferrer">https://0bin.net/paste/ZleyLDeOcgr3kj-e#OPVr3oIC8-mcO9mXB1pV/+ONcdnUB+3I1RCy37/NI+p</a></p>
  
  <p><a href="https://0bin.net/paste/+rbHWsKmXhIXM50A#PaAFLCeDJZzIQTWczYbDepmubFhSaeDWqzcB+ItUTnb" rel="nofollow noreferrer">https://0bin.net/paste/+rbHWsKmXhIXM50A#PaAFLCeDJZzIQTWczYbDepmubFhSaeDWqzcB+ItUTnb</a></p>
  
  <p><a href="https://0bin.net/paste/VdNv2NA8K0--ZXNM#fomzOVZ9iNOJDHequiSAbuv6I3lxDXXL+E5WK6GPKZv" rel="nofollow noreferrer">https://0bin.net/paste/VdNv2NA8K0--ZXNM#fomzOVZ9iNOJDHequiSAbuv6I3lxDXXL+E5WK6GPKZv</a></p>
  
  <p><a href="https://0bin.net/paste/zcDPoycv5lqbjRcA#h0WNQdMSU4VtdIbwzOByW5csu68FERPvEdOKJz9oUeA" rel="nofollow noreferrer">https://0bin.net/paste/zcDPoycv5lqbjRcA#h0WNQdMSU4VtdIbwzOByW5csu68FERPvEdOKJz9oUeA</a></p>
  
  <p>Copy this and paste it into ctrl+f find:</p>
  
  <pre><code>function _JS_Log_Dump(ptr, type) {
  var str = Pointer_stringify(ptr);
  if (typeof dump == "function") dump(str);
  switch (type) {
  case 0:
  case 1:
  case 4:
  console.error(str);
  return;
  case 2:
  console.warn(str);
  return;
  case 3:
  case 5:
  console.log(str);
  return;
  default:
  console.error("Unknown console message type!");
  console.error(str);
  }
  }
  </code></pre>
  
  <p>the lines that are in question are</p>
  
  <pre><code>case 4:
  console.error(str);
  </code></pre>
  
  <p>I have included System.Data.dll and MySql.Data.dll to my Visual Studio references, and also all the I18N files. I have also put those files in my built project file path.</p>
  
  <p>Please tell me if you need additional information, I tried to include everything I thought was relevant.</p>