title: Cannot bind to the target method when creating delegates for properties
body: <p>Trying to create two dictionaries of emitted delegates to allow for improved performance when dynamically getting/setting the values of properties.</p>
  
  <p>Code:</p>
  
  <pre><code>  Properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance)
                      .Where(p =&gt; p.CanRead &amp;&amp; !p.GetIndexParameters().Any())
                      .AsEnumerable();
    PropertyGetters = Properties.ToDictionary(p =&gt; p.Name, p =&gt; (Func&lt;object, object&gt;)Delegate.CreateDelegate(typeof(Func&lt;object, object&gt;), p.GetGetMethod()));
    PropertySetters = Properties.Where(p =&gt; p.GetSetMethod() != null)
                      .ToDictionary(p =&gt; p.Name, p =&gt; (Action&lt;object, object&gt;)Delegate.CreateDelegate(typeof(Action&lt;object, object&gt;), p.GetSetMethod()));
  </code></pre>
  
  <p>However I get the following exception:</p>
  
  <blockquote>
    <p>Cannot bind to the target method because its signature or security
    transparency is not compatible with that of the delegate type.</p>
  </blockquote>
  
  <p>From what I have read this will be caused by static/indexed/value type properties, the <code>Properties</code> collection contains no static or indexed properties but I do however need this to work for value type properties such as <code>int</code> and <code>double</code>.</p>
  
  <p>How can I create the getters/setters that I need while keeping my code abstract and avoiding generics?</p>