NAPI Crashes with System.Reflection.TargetParameterCountException

Recommended Posts

Server crashed with no message when a player connected. 


In the logs I could't find something, but there is no StackTrace in logs and I can not understand anything.

==================[9.12.2018 12:46:10]==================
System.Reflection.TargetParameterCountException: Parameter count mismatch.
   at object[] System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)


Most probably reason is a Event takes only 1 argument but API tries to put it as object[] like:

(via: System.Reflection.TargetParameterCountException: Parameter count mismatch on StackoverFlow)

var obj = "MyParam1"; //Comes from client 

//uses this
method.Invoke(instance, obj);

//instead of this.
method.Invoke(instance, new [] { obj });

//or this control doesn't exist
if(obj is IEnumerable)
 method.Invoke(instance, obj);
 method.Invoke(instance, new [] { obj });


I really can't find the problem. Log isn't enough to find exception. Because exception throws in external assembly and it doesn't have information enough.


-- EDIT--

I've commented all ServerEvents, and there is no problem. I tried uncomment one by one, but I recognized, I can't use any of ServerEvent. 

I uncommented PlayerConnected and crashed again when player connects. same thing happens PlayerDisconnected.

 Reflection doesn't triggers my ServerEvents. Can I handle events with different way instead of Attributes ?


Edited by enisn

Share this post

Link to post
Share on other sites



EDIT: THe solution seems to be to copy Bootstrapper.dll from bridge_package.zip to NuGet package folder, aka C:\Users\KevY\.nuget\packages\gtanetwork.api\0.3.6\lib\netcoreapp2.0

Edited by KevY

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.

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.

  • Recently Browsing   0 members

    No registered users viewing this page.