Author Topic: MissingMethodExceptions in 1.9.6  (Read 1967 times)

luvcraft

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 11
    • View Profile
MissingMethodExceptions in 1.9.6
« on: July 14, 2014, 02:26:14 PM »
I just updated to 1.9.6 and immediately got a bunch of MissingMethodExceptions trying to read my custom classes in from DataNodes, because apparently TNet now expects all custom classes' constructors to take exactly one int as an argument (my classes' constructors take no arguments). I fixed it by changing the Create function at TNSerializer line 272 to the following:

  1.    static public object Create (this Type type, int size)
  2.    {
  3.       try
  4.       {
  5.          return Activator.CreateInstance(type, size);
  6.       }
  7.       catch (Exception ex)
  8.       {
  9.             try
  10.             {
  11.                 return Activator.CreateInstance(type);
  12.             }
  13.             catch (Exception ex2)
  14.             {
  15.                 Debug.LogError(ex2.Message + " | " + ex2.GetType());
  16.                 return null;
  17.             }
  18.       }
  19.    }
  20.  
« Last Edit: July 14, 2014, 02:47:34 PM by luvcraft »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: MissingMethodExceptions in 1.9.6
« Reply #1 on: July 15, 2014, 01:11:18 AM »
Thanks for pointing that out, but I think it might be better to change DataNode line 872 instead:
  1. mValue = type.Implements(typeof(TList)) || type.Implements(typeof(System.Collections.IList)) ?
  2.         type.Create(children.size) : type.Create();

luvcraft

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 11
    • View Profile
Re: MissingMethodExceptions in 1.9.6
« Reply #2 on: July 15, 2014, 12:16:07 PM »
changing that line on DataNode but leaving TNSerializer as it was still gives me errors when I try to read in a TList of my custom class (it does, however, work just fine with the nested-try fix I suggested)

EDIT: This is fixed in 1.9.6b. Thanks!
« Last Edit: July 15, 2014, 01:37:03 PM by luvcraft »