From 25024c01dd8795eb139d4f0dfad77e7df3fd9a26 Mon Sep 17 00:00:00 2001 From: Solal Pirelli Date: Tue, 4 Aug 2015 01:01:20 +0200 Subject: [PATCH] Fix an access violation error on WP 8.1. --- ThriftSharp/Internals/ThriftClientMessageReader.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ThriftSharp/Internals/ThriftClientMessageReader.cs b/ThriftSharp/Internals/ThriftClientMessageReader.cs index dd4e3a4..7cb3292 100644 --- a/ThriftSharp/Internals/ThriftClientMessageReader.cs +++ b/ThriftSharp/Internals/ThriftClientMessageReader.cs @@ -59,7 +59,11 @@ private static LambdaExpression CreateReaderForMethod( ThriftMethod method ) Expression.IsFalse( Expression.Call( Methods.Enum_IsDefined, - Expression.Constant( typeof( ThriftMessageType ) ), + // The second argument is absolutely crucial here. + // System.Type is an abstract class, implemented by an internal framework class System.RuntimeType + // Not specifying the argument leads to the expression's type being typeof(System.RuntimeType), + // which crashes on frameworks that restrict access to non-public framework types, such as Windows Phone 8.1 + Expression.Constant( typeof( ThriftMessageType ), typeof( Type ) ), Expression.Convert( Expression.Field( headerVariable, Fields.ThriftMessageHeader_MessageType ), typeof( object )