Unity C# SFSArrayLite cast Exception

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

Posts: 26
Joined: 30 Apr 2016, 07:23
Location: Turkey

Unity C# SFSArrayLite cast Exception

Postby ersindemir » 26 Jan 2017, 13:32

Backend code (Java)
Collection<Integer> data = new ArrayList();
sfsObj.putIntArray("data", data);

I got exception from Client side when I try this code;

InvalidCastException: Unable to cast object of type 'SFSArrayLite' to type 'Int32[]'.
at Sfs2X.Entities.Data.SFSObject.GetValue[Object] (System.String key) [0x00000] in <filename unknown>:0

Unity version : 5.5.0f3
Smartfox Client version : 1.6.6
Smartfox Backend version : 2.9.2 ( Same error 2.12.0)
Plaform : WebGL (No problem on Android , IOS)
User avatar
Site Admin
Posts: 4385
Joined: 29 Mar 2005, 09:50
Location: Italy

Re: Unity C# SFSArrayLite cast Exception

Postby Bax » 27 Jan 2017, 09:19

Actually the GetValue method is an internal method that you should not use.
Please use sfsObject.GetIntArray(). This should fix it.

PS: we will make that method private in future releases of the API, to avoid this situation.
Paolo Bax
The SmartFoxServer Team

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 1 guest