Skip to content

Commit 24fc423

Browse files
committed
TryCast fix to allow cast null object to any type.
(cherry picked from commit a480101)
1 parent c94dd1f commit 24fc423

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Mono.Debugging.Win32/CorObjectAdaptor.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,10 @@ public override object TryCast (EvaluationContext ctx, object val, object type)
688688
{
689689
var ctype = (CorType) GetValueType (ctx, val);
690690
CorValue obj = GetRealObject(ctx, val);
691+
var referenceValue = obj.CastToReferenceValue ();
692+
if (referenceValue != null && referenceValue.IsNull)
693+
return val;
694+
691695
string tname = GetTypeName(ctx, type);
692696
string ctypeName = GetValueTypeName (ctx, val);
693697
if (tname == "System.Object")

0 commit comments

Comments
 (0)