Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Samsung smart TV serialize / deserialize error advice plz

Discussion in 'Samsung Smart TV' started by KIMHYUNJIN, May 18, 2016.

  1. KIMHYUNJIN

    KIMHYUNJIN

    Joined:
    May 13, 2016
    Posts:
    2
    using a version unity3D5.3.3f1 underway webplayer based operations.
    Files can not be stored in the data processing and webplayer
    PlayerPrefs the data processing is possible only

    public enum TEST_TYPE {
    None,
    Test_1
    }

    [Serializable]
    public class TestClass
    {
    public int nTestint = 0;
    public bool nTestbool = true;

    }
    [Serializable]
    public class Test {
    public string testUser = "User";
    public List<TestClass> listTest = new List<TestClass>();
    public Dictionary<TEST_TYPE ,int> dicTest = new Dictionary<TEST_TYPE, int>();

    Test() {

    }
    }

    public static void Save() {
    BinaryFormatter bf = new BinaryFormatter();
    MemoryStream memoryStream = new MemoryStream();
    Test sTest = new Test ();
    bf.Serialize(memoryStream, Test);
    string tmp = System.Convert.ToBase64String(memoryStream.ToArray());
    PlayerPrefs.SetString("TEST", tmp);
    }

    public static void Load() {
    string tmp = PlayerPrefs.GetString("TEST", string.Empty);
    if (tmp == string.Empty)
    return;
    BinaryFormatter bf = new BinaryFormatter();
    MemoryStream memoryStream = new MemoryStream(System.Convert.FromBase64String(tmp));
    Test sTest = new Test ();
    Test = (Test)bf.Deserialize(memoryStream);
    }

    Like the above Serialize / Deserialize the process by working.
    The unity is the normal data processing.
    The problem is in the process if you run Deserialize pulled build
    It causes the following aereo.
    List, and when annotating Dictionary will be processed. (Write current situation)

    FieldAccessException: Attempt to access a private/protected field failed. at System.Reflection.MonoField.SetValue (System.Object obj, System.Object val, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 at System.Reflection.FieldInfo.SetValue (System.Object obj, System.Object value) [0x00000] in <filename unknown>:0 at System.Runtime.Serialization.ObjectRecord.SetMemberValue (System.Runtime.Serialization.ObjectManager manager, System.Reflection.MemberInfo member, System.Object value) [0x00000] in <filename unknown>:0 at System.Runtime.Serialization.FixupRecord.FixupImpl (System.Runtime.Serialization.ObjectManager manager) [0x00000] in <filename unknown>:0 at System.Runtime.Serialization.BaseFixupRecord.DoFixup (System.Runtime.Serialization.ObjectManager manager, Boolean strict) [0x00000] in <filename unknown>:0 at System.Runtime.Serialization.ObjectRecord.DoFixups (Boolean asContainer, System.Runtime.Serialization.ObjectManager manager, Boolean strict) [0x00000] in <filename unknown>:0 at System.Runtime.Serialization.ObjectManager.RegisterObjectInternal (System.Object obj, System.Runtime.Serialization.ObjectRecord record) [0x00000] in <filename unknown>:0 at System.Runtime.Serialization.ObjectManager.RegisterObject (System.Object obj, Int64 objectID, System.Runtime.Serialization.SerializationInfo info, Int64 idOfContainingObj, System.Reflection.MemberInfo member, System.Int32[] arrayIndex) [0x00000] in <filename unknown>:0 at System.Runtime.Serialization.Formatters.Binary.ObjectReader.RegisterObject (Int64 objectId, System.Object objectInstance, System.Runtime.Serialization.SerializationInfo info, Int64 parentObjectId, System.Reflection.MemberInfo parentObjectMemeber, System.Int32[] indices) [0x00000] in <filename unknown>:0 at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadValue (System.IO.BinaryReader reader, System.Object parentObject, Int64 parentObjectId, System.Runtime.Serialization.SerializationInfo info, System.Type valueType, System.String fieldName, System.Reflection.MemberInfo memberInfo, System.Int32[] indices) [0x00000] in <filename unknown>:0 at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadGenericArray (System.IO.BinaryReader reader, System.Int64& objectId, System.Object& val) [0x00000] in <filename unknown>:0 at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObject (BinaryElement element, System.IO.BinaryReader reader, System.Int64& objectId, System.Object& value, System.Runtime.Serialization.SerializationInfo& info) [0x00000] in <filename unknown>:0 at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadNextObject (System.IO.BinaryReader reader) [0x00000] in <filename unknown>:0 at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObjectGraph (BinaryElement elem, System.IO.BinaryReader reader, Boolean readHeaders, System.Object& result, System.Runtime.Remoting.Messaging.Header[]& headers) [0x00000] in <filename unknown>:0 at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.NoCheckDeserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler) [0x00000] in <filename unknown>:0 at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream) [0x00000] in <filename unknown>:0

    Reference
    mosterbank blog
    http://monsterbank.tistory.com/search/unity web

    unity community
    http://answers.unity3d.com/questions/584269/webplayer-deserialization-fails.html

    I saw how the information to be processed or the other side in the Web Play
    If you are interested, if you like solving minute advice, please, please.
     
  2. AlexThibodeau

    AlexThibodeau

    Unity Technologies

    Joined:
    Jul 23, 2013
    Posts:
    309
    If I understand correctly it looks like you are attempting to write to the file system from a unity process. This is not allowed for security reasons on Samsung TV. Currently the only way to store data on the TV is via player preferences.