Comments (13)
Hi, probably you have different BCL assemblies on serialization and de-serialization endpoints. Are you using .NET Core or some WinRT runtime?
from msgpack-unity3d.
Unity (5.6.2f1) Project Settings for ios build:
Scripting Backend: IL2CPP
Api Compatibility Level: .NET 2.0
Server:
.NET Framework 3.5
from msgpack-unity3d.
Hmmm.
Could you provide MessagePack serialized data for test? The same which gives you exception above.
from msgpack-unity3d.
Also could you try this commit 268ef86 (last one in this repository)?
from msgpack-unity3d.
So, about serialized data for the test.
ErrorSystem.Exception: Can`t parse packet, length:138 new byte[] { 131, 165, 95, 116, 121, 112, 101, 187, 80, 114, 111, 116, 111, 99, 111, 108, 46, 84, 101, 115, 116, 73, 110, 102, 111, 44, 32, 80, 114, 111, 116, 111, 99, 111, 108, 163, 85, 73, 68, 217, 36, 101, 52, 56, 51, 52, 54, 99, 99, 45, 101, 54, 52, 49, 45, 52, 102, 55, 52, 45, 57, 99, 55, 100, 45, 51, 57, 52, 54, 54, 51, 99, 102, 55, 56, 55, 51, 171, 68, 101, 99, 111, 114, 97, 116, 105, 111, 110, 115, 145, 130, 165, 95, 116, 121, 112, 101, 184, 80, 114, 111, 116, 111, 99, 111, 108, 46, 68, 101, 99, 111, 114, 44, 32, 80, 114, 111, 116, 111, 99, 111, 108, 168, 80, 111, 115, 105, 116, 105, 111, 110, 130, 161, 88, 0, 161, 89, 13 } ---> System.Runtime.Serialization.SerializationException: Failed to read value for member 'Decorations' of 'TestInfo' type.
public class Point<TCoord> where TCoord : struct
{
public TCoord X;
public TCoord Y;
}
public class Decor
{
public Point<byte> Position;
}
public class TestInfo : ServerPacket
{
public Decor[] Decorations;
}
Decor and TestInfo have a Protocol namespace and Point - Protocol.Types.
{
"$type": "Protocol.TestInfo, Protocol",
"Decorations": [
{
"$type": "Protocol.Decor, Protocol",
"Position": {
"$type": "Protocol.Types.Point`1[[System.Byte, mscorlib]], Protocol",
"X": 0,
"Y": 13
}
}
]
}
from msgpack-unity3d.
Thanks for test data! I will check it.
from msgpack-unity3d.
Actually in your test data there is no type information for Point
type.
Here is ASCII: "??_type?Protocol.TestInfo, Protocol?UID?$e48346cc-e641-4f74-9c7d-394663cf7873?Decorations???_type?Protocol.Decor, Protocol?Position??X\u0000?Y\u000D"
.
As workaround you could suppress all type information in your messages until inheritance or serialization by the base type (like object values in dictionaries) being involved.
This will be faster and safer from security concern.
MsgPack.Serialize(... SerializationOptions.SuppressTypeInformation);
from msgpack-unity3d.
There is no type information for Point type because I used custom serializer, I think.
Here's the example which gives the exception too.
public class Decoration
{
public int BuildingId;
public Point<byte> Position;
}
namespace Protocol.CityBuilder
[131][165]_type[217])Protocol.CityBuilder.Decoration, Protocol[170]BuildingId[209][1][245][168]Position[131][165]_type[217]9Protocol.Types.Point`1[[System.Byte, mscorlib]], Protocol[161]X[0][161]Y[13]
{131, 165, 95, 116, 121, 112, 101, 217, 41, 80, 114, 111, 116, 111, 99, 111, 108, 46, 67, 105, 116, 121, 66, 117, 105, 108, 100, 101, 114, 46, 68, 101, 99, 111, 114, 97, 116, 105, 111, 110, 44, 32, 80, 114, 111, 116, 111, 99, 111, 108, 170, 66, 117, 105, 108, 100, 105, 110, 103, 73, 100, 209, 1, 245, 168, 80, 111, 115, 105, 116, 105, 111, 110, 131, 165, 95, 116, 121, 112, 101, 217, 57, 80, 114, 111, 116, 111, 99, 111, 108, 46, 84, 121, 112, 101, 115, 46, 80, 111, 105, 110, 116, 96, 49, 91, 91, 83, 121, 115, 116, 101, 109, 46, 66, 121, 116, 101, 44, 32, 109, 115, 99, 111, 114, 108, 105, 98, 93, 93, 44, 32, 80, 114, 111, 116, 111, 99, 111, 108, 161, 88, 0, 161, 89, 13}
from msgpack-unity3d.
I can't repoduce it on iOS and IL2CPP. Are you sure Packet types are not stripped ('Protocol' assembly is specified in link.xml) and strong linked (has references) to Unity's project assembles?
from msgpack-unity3d.
'Protocol' assembly didn't specify in link.xml. I have problem just with generic type Point. I will try it and write about a result.
from msgpack-unity3d.
Should I use your last commit for the check is it stable changes?
from msgpack-unity3d.
from msgpack-unity3d.
May you show the example how should correctly Packet types link with Unity project? Also how correctly build dll with your last commit for Unity project?
Just add info into link.xml like this?
<linker>
<assembly fullname="Protocol">
<type fullname="Protocol.Types.Point" preserve="all" />
<namespace fullname="Protocol.Types" preserve="all" />
</assembly>
</linker>
from msgpack-unity3d.
Related Issues (20)
- ReflectionExtensions.GetDataMemberName doesn't work under WebGL in Unity HOT 3
- Got an exception in WebGL build on MsgPack.Deserialize<IndexedDictionary<string, object>>(s); HOT 6
- Ignore Getters HOT 1
- Compatibility with notepack.io's "undefined" value HOT 5
- BeginDeserialize/EndDeserialize HOT 2
- Guid de-serialization HOT 3
- Exposing JsonSerializationException.ErrorCode HOT 3
- Unexpected value when deserializing (int) HOT 5
- Json deserialization of null primitive types HOT 2
- Vector Crash HOT 6
- [Request] Support for Unity 2018.3.0f2 (Script Runtime Version .NET 4.x) HOT 4
- .NET Standard 2.0 HOT 5
- Decode bytes starting from offset HOT 3
- 'Unexpected token readed 'EndOfStream' while 'BeginObject' is expected.' ? HOT 4
- Unexpected token readed 'BeginArray' while 'BeginObject' is expected. HOT 6
- MsgPackReader.cs ReadBytes(long bytesRequired, bool forceNewBuffer = false) Problem HOT 5
- Can not JSON serialize an IndexedDictionary HOT 2
- "Invalid cast"? HOT 3
- [question] problem encoding types HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from msgpack-unity3d.