FindPropertyInfo is used at three different places but the result was only checked in one place (the SetPropertyValue method). Now the result is checked inside the FindPropertyInfo method itself to make sure we have a proper exception rather than a NullReferenceException when accessing propertyInfo.PropertyType on a null propertyInfo.
Also, the message of the exception has been improved to give a hint about the probable root cause of the issue.
Finally, wrap Program.Run in a try/catch so that we can read the exception and decide to close the console by pressing a key.
FindPropertyInfo is used at three different places but the result was only checked in one place (the SetPropertyValue method). Now the result is checked inside the
FindPropertyInfo
method itself to make sure we have a proper exception rather than aNullReferenceException
when accessingpropertyInfo.PropertyType
on a nullpropertyInfo
.Also, the message of the exception has been improved to give a hint about the probable root cause of the issue.
Finally, wrap Program.Run in a try/catch so that we can read the exception and decide to close the console by pressing a key.