locked
"Parameter count mismatch" TargetParameterCountException

    Question

  • Hi

     

    I may be missing some very basic logic, but My Problem has eaten up several Days & brains.

     

    I have a Card Game Server (in C#), and Several Game Clients (in C#).

    I am using Socket Class and used the Socket.Send(byte[] buffer); API for sending Data on both Server & Client

    The Un-bearable behaviour I'm seeing is that despite of Server successfully sending using same logic

    Client Application crashes on the Socket.Send() API leaving me with a "TargetParameterCountException"

     

    I've searched MSDN, found out that Send() function doesn't Throws such an exception.

     

    Also exception Message is Parameter count mismatch, however the Send() function has this one agument overload.

     

    Code Snippet

     

    Public void SendMessage(String msg)

    {

    if(ClientSocket!=null)

    {

    if(ClientSocket.Connected)

    {

    ClientSocket.Send(Encoding.ASCII.GetBytes(msg));

    }

    }

    }

     

     

    this is the Exception Dump..........can....Anyone........Help????

     

    See the end of this message for details on invoking
    just-in-time (JIT) debugging instead of this dialog box.

    ************** Exception Text **************
    System.Reflection.TargetParameterCountException: Parameter count mismatch.
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Delegate.DynamicInvokeImpl(Object[] args)
       at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
       at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
       at System.Windows.Forms.Control.InvokeMarshaledCallbacks()


     

    Thursday, July 26, 2007 3:39 PM

Answers

  • Hey Guys

    The issue was closed long time back...However I didnt updatet his Post

    It was a kiddish error. The Exception was thrown because the Function being referenced by
    a delegeate had less number of Arguments than the Delegate Signature.

    However, one important thing to note was the Exception was being captured when I reached Socket.send() call

    Threads...and their Debugging still have a long way to go....

    Thanks Everyone for Help

    System Engineer, TCS
    Wednesday, August 19, 2009 11:50 AM

All replies

  • This is not because of the Socket.Send(), This represents the error that occurs when the number of parameters passed in the invocation of a member does not match the number of parameters required by the contract of that member.

     

    You might want to check this System.Reflection.TargetParameterCountException Class

    Friday, July 27, 2007 8:16 AM
  • Karthikeya............I know wat u say.......

     

    But I have Debugged the Code........And the Exception is Thrown on the Socket.Send() APi call

     

    The Exception is Same.

     

    Friday, July 27, 2007 2:36 PM
  • Hey Guys

    The issue was closed long time back...However I didnt updatet his Post

    It was a kiddish error. The Exception was thrown because the Function being referenced by
    a delegeate had less number of Arguments than the Delegate Signature.

    However, one important thing to note was the Exception was being captured when I reached Socket.send() call

    Threads...and their Debugging still have a long way to go....

    Thanks Everyone for Help

    System Engineer, TCS
    Wednesday, August 19, 2009 11:50 AM