I need to get a dictionary of properties and their values from an object declared with the dynamic keyword in .NET 4? It seems using reflection for this will not work.
In the case of ExpandoObject, the ExpandoObject class actually implements IDictionary
for its properties, so the solution is as trivial as casting:
IDictionary propertyValues = (IDictionary)s;
Note that this will not work for general dynamic objects. In these cases you will need to drop down to the DLR via IDynamicMetaObjectProvider.