Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does ExpandoObject not work as expected? [closed]

Tags:

c#

.net

dynamic

Currently, not even the simplest examples of using the 'ExpandoObject' work on my machine.

Both

dynamic obj = new ExpandoObject();
obj.Value = 10;
var action = new Action<string>((line) => Console.WriteLine(line));
obj.WriteNow = action;
obj.WriteNow(obj.Value.ToString());

(from this website) and

dynamic sampleObject = new ExpandoObject();
sampleObject.test = "Dynamic Property";
Console.WriteLine(sampleObject.test);

(from the MSDN examples) fail with a RuntimeBinderException. I presume I've misconfigured something, but I am at a loss about what it might be.

I am using .NET v4.0.30319 and Visual Studio 2010 SP1 Premium. Please ask for anything else you might need to know. =)

like image 956
Jens Avatar asked Nov 04 '22 19:11

Jens


1 Answers

Deleting the hidden "SolutionName.suo" file in the solution directory fixed this problem for me.

I still have no clue why it occured, though.

Edit: Andras Zoltan, who deleted his answer, guessed correctly. I have had "Break on all Exceptions" enabled and was being stupid. =)

like image 87
Jens Avatar answered Nov 15 '22 01:11

Jens