title: c# Reflection change get method of a property
body: <p>In my C# project I have a dependency on a 3rd party library. Now I want to write an automated acceptance test for my project. However to invoke the test I need an instance of a class from the 3rd party library. Using reflection I managed to set the values as I needed them apart from one.</p>
  
  <p>Here is the relevant class that I am having the issue with:</p>
  
  <pre><code>public class SystemResults
  {
      // There must be something like this. However I cannot see it as it is private.
      private List&lt;Positions&gt; xyz = new List&lt;Positions&gt;();
  
      public IList&lt;Positions&gt; Positions
      {
          get
          {
              return xyz;
          }
  
          // This property does not have a set method
      }
  }
  </code></pre>
  
  <p>Here is what I have tried so far:</p>
  
  <pre><code>private void InitSystemResults(Type trueSysResType, SystemResults sysRes)
  {
      List&lt;Position&gt; positions = ImporterTools.GetPositions(PositionsCsv);
      trueSysResType.GetProperty("Positions").SetValue(sysRes, positions); // ==&gt; Here I get an exception
  }
  </code></pre>
  
  <p>When I invoke the <code>SetValue()</code> method the following exception is thrown.</p>
  
  <blockquote>
    <p>System.ArgumentException : Property set method not found.</p>
  </blockquote>
  
  <p>From this information I figured out, that the class must look as I described above.</p>
  
  <p>Now I would like to proceed with this some how. Has anybody an idea how I can achieve that when I access <code>sysRes.Positions</code> my <code>positions</code> are returned by the get method? Or is there a way to change the get method?</p>