0

This is supported by binary formatter, not sure if it is supported by Protobuf-net. I've tried it by treating it as normal protobuf-net member, but got error complaining "No serializer defined for type: System.Func ..."

inethui
  • 23
  • 4
  • You can’t serialize code. What are you wanting to accomplish? – Daniel A. White Apr 20 '22 at 17:43
  • Serializing delegates with `BinaryFormatter` is a bad idea. It doesn't serialize the code, it serializes some internal class that captures the point where the delegate was compiled + the delegate's arguments. The problem is that the class name is generated at compile time, and code changes can cause different names to be chosen, resulting in the wrong delegate getting deserialized from old files. So, don't do it. See [how come BinaryFormatter can serialize an Action<> but Json.net cannot](https://stackoverflow.com/q/49138328/3744182) for details. – dbc Apr 20 '22 at 18:49
  • 1
    That is a really helpful information, thanks for sharing the link. – inethui Apr 20 '22 at 21:47

0 Answers0