I am utilizing protobuf-net for a project, and have a class that contains a double?[] member. As some of the values can be null, I need to run the following line of code:
RuntimeTypeModel.Default[typeof(MyType)][1].SupportNull = true;
I put this code in the static initializer for the class (e.g., in static MyType() { ... }), but when I run, I get an InvalidOperationException with the message "The type cannot be changed once a serializer has been generated". I suspect that this is due to the serializer being generated prior to the class being referenced for the first time. Does anyone know where to put this line of code so it always runs prior to serializer creation?