c# - InvalidCastException in Mono when trying to GetValue() on an IEnumerable -


i'm in process of creating binding solution within mono enables developers have two-way binding. property types work except ienumerable, in reason mono throws invalidcastexception whenever event attempt try , use propertyinfo.getvalue() it.

even though propertyinfo shows signs collection<> / ienumerable<> finding type correctly (ie if debug, shows property being passed in derives collection...but can't extract actual value?

here's code:

var src = source.gettype().getproperty("foo"); if (typeof (ienumerable).isassignablefrom(sourceproperty.propertytype)) {     var obj = src.getvalue(source, null); } 

the error get:

invalidcastexception: cannot cast source type destination type.

system.reflection.monoproperty.getteradapterframe[vmcontroller,array] (system.reflection.getter`2 getter, system.object obj) (at /users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/system.reflection/monoproperty.cs:234) system.reflection.monoproperty.getvalue (system.object obj, system.object[] index) (at /users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/system.reflection/monoproperty.cs:292)


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -