The code below works great. If the Get
and Use
methods are in different assemblies, the code fails with a RuntimeBinderException. This is because t
Here's a poor man's workaround; Newtonsoft.Json to the rescue, as serialization roundtrip generates dynamic type instances visible to your/working assembly.
public static class TypeExt
{
// roundtrip json serialization to enable access to dynamic members and properties originating from another assembly
public static T JClone( this T source ) { return JsonConvert.DeserializeObject( JsonConvert.SerializeObject( source ) ); }
}