No suitable default type encoding was found. When serialized using protobuf

I have a class: -

[Serializable]
[DataContract(Name = "StateValueWrapper")]
public class StateValueWrapper
{
    [DataMember(Order = 1)]
    public Type StateValueType { get; set; }

    [DataMember(Order = 2)]
    public object WrappedObj { get; set; }
}

I am trying to serialize an object above a class using protobuf.net.While serializing the receipt of the error "There is no suitable encoding of the default type." please suggest me what do i need to do for this? Below is my serialization code: -

            MemoryStream ms = new MemoryStream();
            var srariazeObj = new StateValueWrapper();
            srariazeObj.StateValueType = typeof(int);
            srariazeObj.WrappedObj = 5;
            ProtoBuf.Serializer.NonGeneric.Serialize(ms, srariazeObj);
+3
source share
2 answers

Type protobuf-net, object. , , . , AssemblyQualifiedName (a string) byte[] ( MemoryStream). , ( ).

, , (, "string int" "Customer" "Guid" "), - , - .

+1

, , StateValueWrapper. WrappedObj StateValueWrapper, protobuf, WrappedObj, StateValueWrapper, . SessionStateItemCollection StateValueWrapper Array, (protobuf) WrappedObj StateValueWrapper.

+1

Source: https://habr.com/ru/post/1789517/


All Articles