Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9225201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:31:08+00:00 2026-06-18T04:31:08+00:00

I have the exception Unexpected sub-type: UnnamedGameServer.TrapInstance while Serializing in protobuf-net. This is the

  • 0

I have the exception Unexpected sub-type: UnnamedGameServer.TrapInstance while Serializing in protobuf-net.

This is the code:

class test
{
    void testMethod(PacketNewTrapResponse packet)
    {
        using (var stream = new MemoryStream())
        {
            Serializer.SerializeWithLengthPrefix<PacketNewTrapResponse>(stream, (PacketNewTrapResponse)packet, PrefixStyle.Base128);
        }
    }
}

[ProtoContract]
public class MapTrap
{
    [ProtoMember(1)]
    public IntegerVector2 Position;
    [ProtoMember(2)]
    public int TrapServerID;
    [ProtoMember(3)]
    public int LocationID;
}

[ProtoContract, ProtoInclude(1, typeof(MapTrap))]
class TrapInstance : MapTrap
{
    public TrapInstance(TrapProperties trap, SessionCharacter session, int serverTrapId, int locationId, IntegerVector2 position)
    {
        TrapServerID = serverTrapId;
        Trap = trap;
        Position = position;
        LocationID = locationId;
        OwnerOfTrap = session;
        LocationID = locationId;
        Position = position;
    }

    public SessionCharacter OwnerOfTrap { get; set; }
    public TrapProperties Trap { get; set; }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:31:09+00:00Added an answer on June 18, 2026 at 4:31 am

    The base-class needs to be told about the sub-classes, not the other way around. From a sub-class it is trivial to look for the base-class, since that is readily available at runtime.

    [ProtoContract, ProtoInclude(5, typeof(TrapInstance))]
    public class MapTrap {...}
    
    [ProtoContract]
    class TrapInstance : MapTrap {...}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm encountering this Exception in my project using Protobuf.net: InvalidOperationException Unexpected sub-type: foo I
I have this exception: org.xml.saxParseException: Unexpected token (position TEXT@1:2...) but it is caused only
I have an exception handler for the type SqlException and I'm looking at the
I have following exception in the foreach loop Unable to cast object of type
I have a Exception base class which defines a stream function: class Exception {
I am new to Hibernate. I have an exception while running an Hibernate-based application.
I have this snippet of the code in ML: local fun unfolder( [] ,
I'd like to use the Storage class with GWT. I have this in my
I have an exception handler defined as following in a Spring controller: @ExceptionHandler(Customized4ExceptionHandler.class) public
I have this code: var url = textBox1.Text; WebClient wc = new WebClient(); var

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.