Sign in to follow this  
ZenzCode

Unhandled Exception: System.Reflection.TargetInvocationException

Recommended Posts

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.