baptiste27140 Posted March 9, 2019 Share Posted March 9, 2019 System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileLoadException: Could not load file or assembly 'MySql.Data, Version=8.0.15.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621) ---> System.IO.FileLoadException: Could not load file or assembly 'MySql.Data, Version=8.0.15.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d'. at void System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, string ilPath, string niPath, ObjectHandleOnStack retAssembly) at Assembly System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(string assemblyPath) at Assembly System.Reflection.Assembly.LoadFrom(string assemblyFile) at Assembly System.Reflection.Assembly.LoadFromResolveHandler(object sender, ResolveEventArgs args) at RuntimeAssembly AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, string assemblyFullName) --- End of inner exception stack trace --- at void ExampleResource.Main.OnPlayerLoginAttempt(Client player, string username, string password) --- End of inner exception stack trace --- at object RuntimeMethodHandle.InvokeMethod(object target, object[] arguments, Signature sig, bool constructor) at object System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(object obj, object[] parameters, object[] arguments) at void GTANetworkInternals.RemoteEventParser.Parse(Client sender, ulong eventNameHash, object[] args) in C:\Users\Adam\Documents\Git\comp-layer2\BootstrapperNC\Handlers\ResourceInfo.cs:line 62 at void GTANetworkInternals.RemoteEventHandler.Parse(Client sender, ulong eventNameHash, object[] arguments) in C:\Users\Adam\Documents\Git\comp-layer2\BootstrapperNC\Handlers\ResourceInfo.cs:line 67 using System; using GTANetworkAPI; using MySql.Data.MySqlClient; namespace ExampleResource { public class Main : Script { private static string db_string; private static string db_host = "127.0.0.1"; private static string db_user = "root"; private static string db_pass = "toor"; private static string db_name = "beroleplay"; [ServerEvent(Event.ResourceStart)] public void OnResourceStart() { NAPI.Util.ConsoleOutput("RolePlay resource loaded!"); db_string = "SERVER=" + db_host + "; DATABASE=" + db_name + "; UID=" + db_user + "; PASSWORD=" + db_pass + "; SSLMODE=required;"; } [RemoteEvent("OnPlayerLoginAttempt")] public void OnPlayerLoginAttempt(Client player, string username, string password) { NAPI.Util.ConsoleOutput($"[Login Attempt] Username : {username} | Password : {password}"); if (LoginAccount(username, password)) { player.TriggerEvent("LoginResult", 1); } else { player.TriggerEvent("LoginResult", 0); } } public static bool LoginAccount(string username, string password) { bool login = false; using (MySqlConnection connection = new MySqlConnection(db_string)) { connection.Open(); MySqlCommand command = connection.CreateCommand(); command.CommandText = "SELECT status FROM users WHERE pseudo = @username AND password = SHA2(@password, '256') LIMIT 1"; command.Parameters.AddWithValue("@username", username); command.Parameters.AddWithValue("@password", password); using (MySqlDataReader reader = command.ExecuteReader()) { login = reader.HasRows; } } return login; } } } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now