diff --git a/hessiancsharp/io/CObjectDeserializer.cs b/hessiancsharp/io/CObjectDeserializer.cs index 11d86fb..3cd0586 100644 --- a/hessiancsharp/io/CObjectDeserializer.cs +++ b/hessiancsharp/io/CObjectDeserializer.cs @@ -53,7 +53,7 @@ public class CObjectDeserializer : AbstractDeserializer /// /// Object type /// - private Type m_type; + private readonly Type m_type; /// /// Hashmap with class fields (<field name><field info instance>) /// @@ -67,7 +67,7 @@ public class CObjectDeserializer : AbstractDeserializer /// deserialized public CObjectDeserializer(Type type) { - this.m_type = type; + m_type = type; for (; type!=null; type = type.BaseType) { FieldInfo [] fields = type.GetFields( @@ -111,17 +111,22 @@ public override object ReadMap(AbstractHessianInput abstractHessianInput) #if COMPACT_FRAMEWORK object result = Activator.CreateInstance(this.m_type); #else - object result = Activator.CreateInstance(this.m_type.Assembly.FullName, this.m_type.FullName).Unwrap(); - // object result = Activator.CreateInstance(this.m_type); - // object result = null; + object result = Activator.CreateInstance( + m_type.Assembly.FullName, + m_type.FullName, + false, + BindingFlags.CreateInstance | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, + null, + null, + null, + null, + null) + .Unwrap(); #endif - return ReadMap(abstractHessianInput, result); - } - /// /// Reads map ///