Giter Site home page Giter Site logo

"Invalid cast"? about msgpack-unity3d HOT 3 CLOSED

endel avatar endel commented on July 23, 2024
"Invalid cast"?

from msgpack-unity3d.

Comments (3)

deniszykov avatar deniszykov commented on July 23, 2024 1

Hi @endel. You are trying to unbox wrong type. Unbox operation is not 'conversion' to desired type it is 'extraction' value of desired type from object.

MessagePack serializer doesn't preserve number type during serialization/deserialization process. It is inherited from message pack format. For example when you serialize 1024(Int32) it would be written as 0xcd[uint 16] token and deserialized as UInt16.

Easiest approach to workaround this problem is to use Convert.ToInt32 method.

from msgpack-unity3d.

endel avatar endel commented on July 23, 2024

This is really annoying :( when the number grows, it cannot be casted to byte anymore, and neither int, but it works for uint.

> message[4]
85113
> (int)message[4]
Invalid cast.
> (byte)message[4]
Invalid cast.
> (uint)message[4]
85113

from msgpack-unity3d.

endel avatar endel commented on July 23, 2024

Awesome, thanks for the clarification!

from msgpack-unity3d.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.