ncupper / protobuf-net

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

Protrobuf - Error : Timeout while inspecting metadata #377

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

I am receiving the following exception

"Timeout while inspecting metadata; this may indicate a deadlock. This can 
often be avoided by preparing necessary serializers during application 
initialization, rather than allowing multiple threads to perform the initial 
metadata inspection; please also see the LockContended event (System.String)"

when attempting to serialize/deserialize an object using protobuf.net. I am 
using the protobuf.net for Silverlight and WCF service. serialize the result on 
WCF service and deserialize the same response on client(Silverlight) end.

I have used extension method for that. here is code for that

 public static byte[] GetSerializeByteArray<T>( this T entity )
    {
          using ( var stream = new MemoryStream() )
            {
                Serializer.Serialize( stream, entity );
                return stream.ToArray();
            }
    }

  public static T DeserializeByteArray<T>( this byte[] byteArray )
    {
        if ( byteArray == null )
        {
            throw new ArgumentNullException( "byteArray" );
        }
        try
        {
            using ( Stream result = new MemoryStream( byteArray ) )
            {
                return Serializer.Deserialize<T>( result );
            }
        }
        catch ( Exception )
        {
            throw new InvalidOperationException( "Invalid Type" );
        }
    }

and here is our model class that reside on other project(Portable Class 
Library) and used on both end client(Silverlight) and server(WCF) end.

 [ProtoContract]
public class Class1
{
    [ProtoMember( 1 )]
    public string Name       
 }

I do not understand that why this exception occurred again and again! Can you 
please explain it to me, Is this a correct way to use protobuf-net 
implementation.

Original issue reported on code.google.com by aady78...@gmail.com on 10 May 2013 at 2:47

GoogleCodeExporter commented 9 years ago
Just to tie things together: 
http://stackoverflow.com/questions/16484254/protrobuf-error-timeout-while-inspec
ting-metadata

Original comment by marc.gravell on 10 May 2013 at 9:47