Bug 4203 - System.ArgumentException: value must be of a primitive type instead of 'Mono.Debugging.Backend.EvaluationResult'
Summary: System.ArgumentException: value must be of a primitive type instead of 'Mono....
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Debugger ()
Version: Trunk
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Jeffrey Stedfast
URL:
Depends on:
Blocks:
 
Reported: 2012-04-03 07:52 UTC by Marek Safar
Modified: 2012-04-11 17:48 UTC (History)
1 user (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 2012-04-03 07:52:01 UTC
using System;
using System.Threading.Tasks;
using System.Threading;

class Tester
{
	async Task<int> Lambda_1()
	{
		int res = 1;
		{
			int a = 8;
			Func<int> f = () => { Thread.Sleep(100000); return a; };
			res = await Task.Factory.StartNew(f);
			res += f();
		}

		return res - 16;
	}

	public static int Main()
	{
		var t = new Tester().Lambda_1();
		if (!Task.WaitAll(new[] { t }, 1000))   // Set a breakpoint here and add t.Start () to Watch window, then expand the result value
			return 1;
		
		return 0;
	}
}


System.ArgumentException: value must be of a primitive type instead of 'Mono.Debugging.Backend.EvaluationResult'
Parameter name: value
  at Mono.Debugger.Soft.VirtualMachine.CreateValue (System.Object value) [0x0005b] in /home/marek/git/monodevelop/main/contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs:165 
  at Mono.Debugging.Soft.SoftDebuggerAdaptor.CreateValue (Mono.Debugging.Evaluation.EvaluationContext ctx, System.Object value) [0x0002f] in /home/marek/git/monodevelop/main/src/addins/MonoDevelop.Debugger.Soft/Mono.Debugging.Soft/SoftDebuggerAdaptor.cs:208 
  at Mono.Debugging.Evaluation.LiteralValueReference.get_Value () [0x0001f] in /home/marek/git/monodevelop/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/LiteralValueReference.cs:79 
  at Mono.Debugging.Evaluation.ValueReference.GetChildren (ObjectPath path, Int32 index, Int32 count, Mono.Debugging.Client.EvaluationOptions options) [0x00002] in /home/marek/git/monodevelop/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/ValueReference.cs:201
Comment 1 Jeffrey Stedfast 2012-04-11 14:05:22 UTC
The cause of this issue is in NRefactoryEvaluator.cs on line 493:

				return LiteralValueReference.CreateObjectLiteral (ctx, name, new EvaluationResult ("No return value."));


Unfortunately I can't get your sample to build, so it's kinda hard to test, but can you try changing that line to call

LiteralValueReference.Create*Target*ObjectLiteral (... ?

I think that should fix this.
Comment 2 Jeffrey Stedfast 2012-04-11 14:12:21 UTC
Just applied this patch to git master of monodevelop, so you could just try that instead of manually editing the sources.
Comment 3 Jeffrey Stedfast 2012-04-11 17:48:49 UTC
Had to follow up with more fixes, but I think I got it now.