title: PropertyDescriptor.SetValue Exception call stack
body: <p>I have some code that uses a PropertyDescriptor to set a value. The problem is that when it fails, the exception does not contain information or a callstack that includes the executed code that threw the exception? In this case SetNameInternal(). The exception only has information up to the point SetValue was invoked. There is no inner exception. Is there any way to get this information so it can be logged? (such as when running the application outside of a debugger)</p>
  <p>The following code demonstrates the issue. The string returned by Exception.ToString() only contains :</p>
  <blockquote>
  <p>System.Exception: Ah!
  at System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object component, Object value)
  at ConsoleApp54.Program.Main(String[] args) ... ConsoleApp54.exe' has exited with code 0 (0x0).</p>
  </blockquote>
  <p>Yet the problem is in SetNameInternal(). Of course in this simple example, it's obvious what is wrong, but a real world case will have a lot more going on, so the callstack is useful.</p>
  <pre><code>    public class Test
  {
      public string Name
      {
          get { return m_name; }
          set
          {
              m_name = value;
              SetNameInternal();
          }
      }
  
      void SetNameInternal()
      {
          throw new Exception(&quot;Ah!&quot;);
      }
  
      private string m_name;
  }
  
  class Program
  {
      static void Main(string[] args)
      {
          var t = new Test();
          try
          {
              PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(t);
              var desc = properties.Find(&quot;Name&quot;, false);
              desc.SetValue(t, &quot;Fail&quot;);
              //but this would return different StackTrace
              //t.Name = &quot;Fail&quot;;
          }
          catch (Exception e)
          {
              Debug.Write(e.ToString());
          }
      }
  }
  </code></pre>
  <p><a href="https://dotnetfiddle.net/A0wshD" rel="nofollow noreferrer">fiddle</a></p>