Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Error after compiling WebGL

Discussion in 'Editor & General Support' started by KonkypenT42, Mar 21, 2018.

  1. KonkypenT42

    KonkypenT42

    Joined:
    Feb 21, 2018
    Posts:
    11
    After compiling the project under WebGL, I open the project in the browser. After loading the project in the window, everything that is displayed is a black screen. Then, after a while, a window with the error text is displayed:
    The application uses a connection to the database, I assume that it is because of this that there are errors. I do the connection to the database in the following way:

    Code (CSharp):
    1. string serverName = "192.168.1.3";
    2.          string userName = "name";
    3.          string dbName = "BaseData";
    4.          string port = "3306";
    5.          string password = "password";
    6.          string connStr = "server=" + serverName +
    7.              ";user=" + userName +
    8.              ";database=" + dbName +
    9.              ";port=" + port +
    10.              ";password=" + password + ";";
    11.          MySqlConnection conn = new MySqlConnection(connStr);
    12.          conn.Open();                                          
    13.          string sql = "SELECT e.id id, c1.x x1, c1.y y1, c1.z z1, c2.x x2, c2.y y2, c2.z z2, p.title " +
    14.              "FROM edge e JOIN place p ON e.place_id = p.id JOIN conjunction c1 ON e.conjunction_start_id = " +
    15.              "c1.id JOIN conjunction c2 ON e.conjunction_end_id = c2.id WHERE `e`.`id` < 940000";
    16.          MySqlCommand command = new MySqlCommand(sql, conn);
    17.          reader = command.ExecuteReader();
    Tell me, maybe I'm doing something wrong, or someone, perhaps, faced such a problem?

    P.S. In the Unity editor, everything works.
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,778
    It might be worth making a development build with full exception support enabled. We should get more details about the cause of the issue from that.
     
  3. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    In addition, some of the code might be stripped. Is MySqlConnectionStringBuilder in its own DLL? We do strip DLLs, but don't strip the code which is compiled from C# code in the project.
     
  4. KonkypenT42

    KonkypenT42

    Joined:
    Feb 21, 2018
    Posts:
    11
    I correctly understand that it is necessary to tick the box next to the "Development Build" field? If yes, then this error appears with this assembly.
     
    Last edited: Mar 23, 2018
  5. KonkypenT42

    KonkypenT42

    Joined:
    Feb 21, 2018
    Posts:
    11
    This library was downloaded from the official site. Then I put it in the "Libraries" folder and everything in the unity editor started working. By the way, if I compile the project in .exe, then the connection to the database occurs without errors and everything works.
     
  6. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    download.png
    You need this setting.

    > "Libraries" folder

    What folder do you mean?

    As I understand the library is in a form of a DLL, so some classes from it might be stripped by Unity and this results in the error you see. Desktop builds are not stripped.
     
  7. KonkypenT42

    KonkypenT42

    Joined:
    Feb 21, 2018
    Posts:
    11
    Now my project has stopped compiling at all and produces errors:

    Tell me, do I need to choose .net 2.0 or .net 2.0 subset?

    Just the folder that I create in "Assets".
     
  8. KonkypenT42

    KonkypenT42

    Joined:
    Feb 21, 2018
    Posts:
    11
    We managed to solve the problem! I dropped the connection to the database and use a controller written in php. I connect to the controller using a plugin that is written in js using an ajax-request. Then, after I get the data from the js plugin in с# I deserialize the data. After that I have full access to my data in the project unity. The main thing is that all this works in WebGL.

    P.S. If someone has encountered a similar problem and does not know how to solve it, then write to me: dimosyav10@gmail.com or skype: KonkypenT-142. I will try to help you with this.