Tom Gullen
Tom Gullen

Reputation: 61773

Unexpected sub-type

Upgraded to v3 from the latest 2.x and getting the error:

Unexpected sub-type: Product

In the method:

internal static byte[] GetBytes<T>(T sourceObject)
{
    using (var stream = new MemoryStream())
    {
        Serializer.Serialize(stream, sourceObject);
        return stream.ToArray();
    }
}

The Product class has the header:

[ProtoContract]
public partial class Product : CachableModel, iDeletable, iFilesUploadable, iUserGeneratedContent

CachableModel has the header:

[ProtoContract]
[ProtoInclude(200, typeof(Product))]
public abstract class CachableModel : BaseObject, iInstanceType
{

And BaseObject has the header:

[ProtoContract]
[ProtoInclude(1, typeof(CachableModel))]
public abstract class BaseObject

Why is this not working?

Upvotes: 1

Views: 351

Answers (1)

Tom Gullen
Tom Gullen

Reputation: 61773

Figured it out, due to AsReference being depricated, serialisation of these properties in Protobuff is no longer possible - however the error message indicates it's a problem with the model itself and not the AsReferenced property.

I can fix this with a lot of refactoring to remove the AsReference requirement in my project.

Upvotes: 1

Related Questions