tonynhan / protobuf-net

Automatically exported from code.google.com/p/protobuf-net
Other
0 stars 0 forks source link

Serialization fails when serializing public fields in Silverlight 2 #64

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Please include an e-mail address if this might need a dialogue!
eMail: federico.lois@gmail.com
==============

What steps will reproduce the problem?
1. Create a simple structure with Fields instead of Properties.. ex:

        [ProtoContract(InferTagFromName = true)]
        public class A
        {
            [ProtoMember(1)]
            public int B;
        }

2. Serialize it using Silverlight 2 with Serializer.Serialize<A>(stream, 
instance);
3. Fails with a MethodAccessException: "Error trying to obtain access to 
the method: System.Reflection.Emit.DynamicMethod..ctor(System.String, 
System.Type, System.Type[], System.Type)"

Stack Trace:  
   at ProtoBuf.Property.Property`2.OnBeforeInit(MemberInfo member, 
Delegate getValue, Delegate setValue, Int32 tag, DataFormat& format)
   at ProtoBuf.Property.Property`1.InitPrivate(Int32 tag, DataFormat 
dataFormat, Boolean isOptional, MemberInfo member, Delegate getValue, 
Delegate setValue, Object defaultValue)
   at ProtoBuf.Property.Property`1.Init(MemberInfo member)
   at ProtoBuf.Property.PropertyFactory.Create[T](MemberInfo member)
   at ProtoBuf.Serializer`1.Build()
   at ProtoBuf.Serializer`1.SerializeChecked(T instance, 
SerializationContext destination)
   at ProtoBuf.SerializerItemProxy`2.Serialize(TActualClass instance, 
SerializationContext destination)
   at ProtoBuf.SerializerProxy`1.Serialize(T instance, Stream destination)
   at ProtoBuf.Serializer.Serialize[T](Stream destination, T instance) 

What is the expected output? What do you see instead?

Correct serialization of public fields (like it works on public 
properties). 

What version of the product are you using? On what operating system?

Latest version of protobuf-net, Silverlight 2, Windows 7.

Original issue reported on code.google.com by federico...@gmail.com on 25 Jul 2009 at 12:26

GoogleCodeExporter commented 8 years ago
OK; will investigate (probably start of next week; a bit hectic this weekend)

Original comment by marc.gravell on 25 Jul 2009 at 9:20

GoogleCodeExporter commented 8 years ago
Any update on this bug?  

Original comment by cape...@gmail.com on 18 Aug 2009 at 4:05

GoogleCodeExporter commented 8 years ago
Sorry, I've been completely maxed out on other work; I'll try to have a look on 
the 
train this morning.

Original comment by marc.gravell on 18 Aug 2009 at 4:24

GoogleCodeExporter commented 8 years ago
Marc, your clever trick for super fast object creation without reflection 
doesn't work 
with the silverlight runtime. Here is a 1 liner  that resolved the 
serialization issues 
for silverlight.

Great work btw!

Original comment by cape...@gmail.com on 18 Aug 2009 at 1:32

Attachments:

GoogleCodeExporter commented 8 years ago
OK; applied - thanks

Original comment by marc.gravell on 18 Aug 2009 at 1:48