Check that you will return from GetSetMethod :
MethodInfo setMethod = propInfo.GetSetMethod(); if (setMethod == null) {
Or, to respond differently to Richard's answer :
if (propInfo.CanWrite && propInfo.GetSetMethod( true).IsPublic) {
Note that if all you want to do is set the property while it has a setter, you actually do not need to worry about whether the setter is publicly available. You can simply use it, public or private:
Dan Tao Sep 21 '10 at 16:39 2010-09-21 16:39
source share