Why is ExpandoObject not working as expected?

Currently, not even the simplest examples of using "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 site) and

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

(from MSDN examples) crash with RuntimeBinderException. I suppose that I configured something incorrectly, but I do not understand what it could be.

I am using .NET v4.0.30319 and Visual Studio 2010 SP1 Premium. Please ask about anything else you may need. =)

+5
source share
2 answers

Deleting the hidden file "SolutionName.suo" in the solutions directory fixes this problem for me.

I still don’t know why this happened.

Edit: , , . "Break on all Exceptions" . =)

+2

, Console.WriteLine , . , . .

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

All Articles