title: PropertyDescriptor - Exception with SetValue() while GetValue() works
body: <p>I have an object that I have defined and I wish to modify one of its property called "DeviceType" using PropertyDescriptor but it's not working out for me. </p>
  
  <p>I can retrieve the value of the property DeviceType but when I use SetValue() to change its property value, I always get the exception: "Object reference not set to an instance of an object" even if I try to set the property to the same value that I just retrieved.</p>
  
  <p>Here is some code: </p>
  
  <pre><code>PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(theBase);
  var objValue = properties["DeviceType"].GetValue(theBase);
  
  try 
  {
      if (theBase != null &amp;&amp; objValue != null)
      {
          properties["DeviceType"].SetValue(theBase, objValue);
      }
  }
  catch (Exception ex)
  {
  
  }
  </code></pre>
  
  <p>Any help would be much appreciated. 
  Thanks.</p>