How to debug (step into) BinaryFormatter.Deserialize()?

前端 未结 3 1192
长发绾君心
长发绾君心 2020-12-10 17:34

My app tries to deserialize data sent by client and it fails with the following error:

Exception thrown: \'System.Runtime.Serialization.Serializatio

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-10 18:00

    Without any details i can assume this is compatibility issue with versions of objects you trying to serialize & deserialize. Looks like client sends you some old object bits(without lambda in constructor). And your server running newer version of software searching for some lambda method.

    <.ctor>b__0 - is method name for first lambda method in .ctor (object constructor).

    So for example if you had on client's machine object A:

    class A {
      public A() {
       int a = 5;
       int b = 7;
       // Plain code, no lambdas
      }
    }
    

    Then you updated your class on server introducing lambda in constructor:

    class A {
      public A() {
       int a = 5;
       int b = 7;
       Func some = x => x * 2 + a; 
      }
    }
    

    After that their binary representation is not the same, server version of A has private invisible method <.ctor>b__0 in it.

提交回复
热议问题