Bug 22193 - System.InvalidCastException: Cannot cast from source type to destination type.
Summary: System.InvalidCastException: Cannot cast from source type to destination type.
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Debugger ()
Version: 5.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: master
Assignee: Jeffrey Stedfast
URL:
Depends on:
Blocks:
 
Reported: 2014-08-19 05:06 UTC by Marek Safar
Modified: 2014-08-19 12:12 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Marek Safar 2014-08-19 05:06:00 UTC
using System;

enum E : long
{
	V = 1
}

class X
{
	static int Main ()
	{
		var e = E.V;
		if (e == 0)
			return 1;

		return 0;
	}
}

Hover over ==

http://screencast.com/t/GJlincbnsv

System.InvalidCastException: Cannot cast from source type to destination type.
  at System.Convert.ToInt64 (System.Object value, IFormatProvider provider) [0x00009] in /Volumes/build-root-ramdisk/mono-3.4.0/mcs/class/corlib/System/Convert.cs:1286 
  at System.Convert.ToInt64 (System.Object value) [0x00009] in /Volumes/build-root-ramdisk/mono-3.4.0/mcs/class/corlib/System/Convert.cs:1279 
  at Mono.Debugging.Evaluation.NRefactoryExpressionEvaluatorVisitor.ConvertToInt64 (System.Object val) [0x00020] in /Users/builder/data/lanes/432/0a7ffa40/source/monodevelop/main/external/debugger-libs/Mono.Debugging/Mono.Debugging.Evaluation/NRefactoryExpressionEvaluatorVisitor.cs:86 
  at Mono.Debugging.Evaluation.NRefactoryExpressionEvaluatorVisitor.EvaluateBinaryOperatorExpression (BinaryOperatorType op, Mono.Debugging.Evaluation.ValueReference left, ICSharpCode.NRefactory.CSharp.Expression rightExp) [0x004eb] in /Users/builder/data/lanes/432/0a7ffa40/source/monodevelop/main/external/debugger-libs/Mono.Debugging/Mono.Debugging.Evaluation/NRefactoryExpressionEvaluatorVisitor.cs:361 
  at Mono.Debugging.Evaluation.NRefactoryExpressionEvaluatorVisitor.VisitBinaryOperatorExpression (ICSharpCode.NRefactory.CSharp.BinaryOperatorExpression binaryOperatorExpression) [0x0001c] in /Users/builder/data/lanes/432/0a7ffa40/source/monodevelop/main/external/debugger-libs/Mono.Debugging/Mono.Debugging.Evaluation/NRefactoryExpressionEvaluatorVisitor.cs:571 
  at ICSharpCode.NRefactory.CSharp.BinaryOperatorExpression.AcceptVisitor[ValueReference] (IAstVisitor`1 visitor) [0x00003] in /Users/builder/data/lanes/432/0a7ffa40/source/monodevelop/main/external/nrefactory/ICSharpCode.NRefactory.CSharp/Ast/Expressions/BinaryOperatorExpression.cs:98 
  at Mono.Debugging.Evaluation.NRefactoryExpressionEvaluator.Evaluate (Mono.Debugging.Evaluation.EvaluationContext ctx, System.String expression, System.Object expectedType) [0x0018e] in /Users/builder/data/lanes/432/0a7ffa40/source/monodevelop/main/external/debugger-libs/Mono.Debugging/Mono.Debugging.Evaluation/NRefactoryExpressionEvaluator.cs:82 
  at Mono.Debugging.Evaluation.ExpressionEvaluator.Evaluate (Mono.Debugging.Evaluation.EvaluationContext ctx, System.String exp) [0x00005] in /Users/builder/data/lanes/432/0a7ffa40/source/monodevelop/main/external/debugger-libs/Mono.Debugging/Mono.Debugging.Evaluation/ExpressionEvaluator.cs:43 
  at Mono.Debugging.Evaluation.ObjectValueAdaptor.GetExpressionValue (Mono.Debugging.Evaluation.EvaluationContext ctx, System.String exp) [0x00003] in /Users/builder/data/lanes/432/0a7ffa40/source/monodevelop/main/external/debugger-libs/Mono.Debugging/Mono.Debugging.Evaluation/ObjectValueAdaptor.cs:1277
Comment 1 Jeffrey Stedfast 2014-08-19 09:36:39 UTC
I think I just fixed this bug yesterday
Comment 2 Jeffrey Stedfast 2014-08-19 12:12:06 UTC
Just confirmed that this is fixed in master. I also back ported the patch to the 5.3 branch.