From 3871c8b73ef7f29c7b392ed4992781fa8634579c Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Thu, 18 Aug 2016 14:06:39 -0400 Subject: [PATCH] Fix serialization of delegates without targets A null check is missing when FEATURE_REMOTING is not defined, resulting in an invalid cast exception when deserializing a delegate without a target (e.g. a delegate for a static method). --- src/mscorlib/src/System/DelegateSerializationHolder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mscorlib/src/System/DelegateSerializationHolder.cs b/src/mscorlib/src/System/DelegateSerializationHolder.cs index 6be712e..a628033 100644 --- a/src/mscorlib/src/System/DelegateSerializationHolder.cs +++ b/src/mscorlib/src/System/DelegateSerializationHolder.cs @@ -221,7 +221,7 @@ namespace System #if FEATURE_REMOTING Object target = de.target != null ? RemotingServices.CheckCast(de.target, targetType) : null; #else - if(!targetType.IsInstanceOfType(de.target)) + if(de.target != null && !targetType.IsInstanceOfType(de.target)) throw new InvalidCastException(); Object target=de.target; #endif -- 2.7.4