Question by
MomoLeFr69 · Dec 07, 2020 at 08:32 PM ·
unity 5buildbuild-errorexception
the type initializer for "Hypixel.NET.Hypixel.Api" threw an exception
Hello, I'm on the development of a statistics application for a game (hypixel <=> minecraft server).
The problem is that the program works on the editor, but generates exceptions on the build.
It generates an exception on the first check; there's an inputfield to fill with a nickname, then it checks if the nickname exists, the code underneath (don't pay attention to the comments, it's in french).
With an exeption.ToString(), it prints the screen below, some ideas about the nature of the error, I tried to change .NET 2.x to 4.x, but it doesn't work.
Note: THERE IS NO EXCEPTION IN EDITOR MODE (tks)
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using Hypixel.NET;
public class GetHypixelApi : MonoBehaviour
{
public HypixelMenu hypixelMenu;
public Text ErrorField;
public void CheckPlayer()
{
try
{
ErrorField.text="";
//Enregistrement de la key Api
var hypixel = new HypixelApi("fa0fdae2-fd5f-47f8-ac71-59951ee7f9f7", 300);
//playerRequest enregistre le pseudo qu'on a écrit
var playerRequest = hypixel.GetUserByPlayerName(hypixelMenu.pseudofill);
if (playerRequest.Player.FirstLogin.ToString() == "01/01/1970 04:00:00")
{
// Le joueur existe mais n'a jamais rejoint le serveur Hypixel
ErrorField.text = "The player has never joined the server";
}
if (ErrorField.text == ""){
hypixelMenu.RedirectionHypixel();
}
}
catch (Exception ex)
{
//Le Pseudo n'existe pas et n'est pas enregistré chez mojang
ErrorField.text = ex.ToString();//"Username not found !";
}
}
// Check si la class return pas null, pour faire marcher la reference "pseudofill"
static void Main(string[] args)
{
var hypixelMenu = new HypixelMenu();
if (hypixelMenu == null)
{
return;
}
}
}
capture.png
(125.0 kB)
Comment