Jump to content

Unhandled Exception: System.Reflection.TargetInvocationException


Recommended Posts

Posted

So I started a script today, and I wanted to add the MySQL.

So the problem is, that i get this

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.Common, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

 at bool RPGerman.RPGerman.Database.PlayerDatabase.isPlayerWhitelisted(Client player)
   at void RPGerman.RPGerman.Main.PlayerConnected(Client player) in /opt/server/ragemp-srv_new_037/C:\Users\Eric\Desktop\RPGerman\bridge\resources\RPGerman\RPGerman\RPGerman\RPGerman\Main.cs:line 26
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at GTANetworkInternals.EventHandler.Parse(Event _event, Object[] arguments)
   at Bootstrapper.EventInternalClass.OnPlayerReady(UInt16 playerId)
Aborted

Error every time I join, because we check for the whitelist.

Here is the code

 

PlayerDatabase:

using System;
using System.Data.Common;
using MySql.Data.MySqlClient;
using GTANetworkAPI;

namespace RPGerman.RPGerman.Database
{
    class PlayerDatabase
    {

        public static string myConnectionString = "SERVER=censored;" + "DATABASE=censored;" + "UID=censored" + "PASSWORD=" + Main.databasePW + ";";
        public static MySqlConnection connection;
        public static MySqlCommand command;
        public static MySqlDataReader reader;

    //SERVER VALUES
    private static int startgeld = 25000;


    public static bool isPlayerWhitelisted(Client player)
    {
        connection = new MySqlConnection(myConnectionString);
        connection.Open();
        command = connection.CreateCommand();
        command.CommandText = "SELECT * FROM whitelist WHERE socialclub = @socialclub";
        command.Parameters.AddWithValue("@socialclub", player.SocialClubName);
        reader = command.ExecuteReader();
        
        while(reader.Read())
        {
            string SocialClubName = reader.GetString("socialclub");
            if(SocialClubName == player.SocialClubName)
            {
                connection.Close();
                return true;
            }
        }
        connection.Close();
        return false;
    }
    }
}

 

JoinEvent:

        [ServerEvent(Event.PlayerConnected)]
        public void PlayerConnected(Client player)
        {
            if(PlayerDatabase.isPlayerWhitelisted(player))
            {
				//do smthg
            }else{
                player.Kick("~r~Du bist nicht auf der Whitelist.");
            }
        }

 

 

Any ideas?

Posted

nothing to do with ur function

System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.Common, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

add this file to runtime folder

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...