Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi

I have a few DLLs which I'm referencing in two test applications, UEClientTest and UEServerTest. The references are UEGameClient.dll and UEGameServer.dll.

In UEClientTest and UEServerTest, there is the following method in class Main:

public void logPacket(PacketDirection direction, string name)
{
    if (InvokeRequired)
    {
        Invoke(new logPacketDelegate(logPacket), direction, name);
    }
    else
    {
        listBox1.Items.Add((direction == PacketDirection.SEND ? "To" : "From") + " client: " + name);
    }
}

private delegate void logPacketDelegate(PacketDirection direction, string name);


That method is called from UEGameClient.dll and UEGameServer.dll respectively, from another thread, hence the delegate and invocation.

The issue is that when I try to use this method, I get the error "Object does not match target type". Example usage:
main.GetType().GetMethod("logPacket").Invoke(main, PacketDirection.SEND, packet.GetType().Name);


Here, "main" is a Form parameter which is passed to this class upon construction.

What I have tried:

---------------------------------------------------------------------------
Posted
Updated 4-Dec-17 1:54am
v2
Comments
________________ 4-Dec-17 2:02am    
The first stupid question:
Is the enum (?) PacketDirection defined only once? Sometimes in big projects simple things could be duplicated, and so, in run time it will not be same type.

1 solution

Solution:

Turns out there’s a weird bug with Visual Studio Professional 2017 which allowed me to build the DLLs even though they had syntax errors, which meant any project which depended on them experienced this strange error.

Several tabs from other projects opened in the wrong projects’ window, so I closed all tabs in every projects, closed all projects, reopened them and saw I had several syntax errors which the editor didn’t detect before.
 
Share this answer
 
Comments
CHill60 4-Dec-17 8:37am    
Please stop posting questions just so that you can answer them yourself.
Reputation point farming is frowned upon and can lead to your account being suspended. If these are genuine cases of you finally finding the answer out for yourself then I suggest you wait a little longer before posting here
[no name] 4-Dec-17 8:39am    
I have no interest in reputation farming, nor have I ever heard of it. When I ask a question, I still try to solve the problem myself. In a few cases, I've managed to solve the problem, so I post the solution in case anyone else is having the same issue. As for your 1-star vote, I couldn't care less.
CHill60 4-Dec-17 8:51am    
1. "a few cases" ... all bar one of the recent solutions I bothered to look at were your own questions, all accepted, no other solutions also accepted. It was this behaviour that led to my comment.
2. Whereas it is good that you have found a solution, other people are unlikely to have the same issue as most of your questions are very specific. The fact you are answering such a high volume of your own questions is suspect behaviour. As I said in my original comment - that behaviour is frowned upon here regardless of what you might call it.
3) The downvote here was indeed from me, although you have no way of knowing that. However, the multitude of other downvotes your solutions have already received were not from me.
4) You will note that I offered a suggestion on how you could avoid the perception of rep-point farming. That advice was offered in good faith, but it is entirely up you whether or not you heed it. I personally don't care either way
[no name] 4-Dec-17 9:00am    
I have nothing to 'fear', if you could call it that, by simply answering some of my own questions. When I ask a question, it's usually because I've tried to solve it by myself for several hours prior. Even though, most of the time these are project-blocking issues, so I ask a question and carry on trying myself to maximise my chances of finding a solution. Some people ask questions without having tried, or give up once they've asked a question and hope for the best. I'm better than that, but apparently it makes you suspicious. I have 340 rep, do you really think boosting it is on my life priorities list? I literally only use this forum when I have no other choice due to how many toxic comments I get and the fact that a bot/basement-dwelling creature is consistently 1-star-voting my questions regardless how much I explain myself and prove my efforts to solve it myself. I know other people are unlikely to have the same problem, but I've always been nagged by higher-ranking members to post the solution and accept it.
[no name] 4-Dec-17 8:48am    
As for "wait a little longer", I posted the question 12 hours ago. It seems you're the kind of person to believe in "guilty until proven innocent" - there's a reason that's not the way most of the world works.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900