Possible Duplicate:
C# 4.0 dynamics
I have a function
void Foo(dynamic thingy)
{
int bar = thingy.Id;
}
and I call it like this
Foo(new {Id=42, Color="red", size = "XL"});
This works fine when Foo and the caller are in the same assembly. But when they are not in the same assembly Foo fails at runtime with RuntimeBinderException saying
'object' does not contain a definition for 'Id'
pointing at the thingy.Id line. A watch in VS shows for sure it has an Id property. Any ideas?
EDIT: this is going to be closed dup. But I thought I would just record that fact that internalsvisibleto assembly attribute worked great - tx manji