title: C# Reflection exception Method not found
body: <p>Hi I'm developing CRM 2011 Plugin and I have a problem with reflected type. I have generated Entities classes and I know that property exists in the type but when I try to get its value I'm getting exception about method not being found. The stupidest part is that it works perfectly on my machine but doesn't work on clients. </p>
  
  <p>Here's my code (I need to take all OptionSets from the entity and perform action on them):</p>
  
  <pre><code>public override void MyExecute()
          {
              var fse = TargetEntity.ToEntity&lt;Equipment&gt;();
              Type equiptmentType = fse.GetType();
              TracingService.Trace("FSE object type: {0}", equiptmentType.FullName);
              IEnumerable&lt;PropertyInfo&gt; optionSetsProperties = equiptmentType.GetProperties()
                  .Where(x =&gt; x.PropertyType == typeof(OptionSetValue)).ToList();  //I'm getting this property from the object type so it must exist.
  
  
              foreach (var optionSetsProperty in optionSetsProperties)
              {   
                  TracingService.Trace("Resolving ResourceGroup on property: {0}", optionSetsProperty.Name);
                  ResolveResourceGroupBySkill(optionSetsProperty, fse);
                  TracingService.Trace("Resoloving ResourceGroup finished");
              }
  
          }
  
  private void ResolveResourceGroupBySkill(PropertyInfo optionSetsProperty, Equipment fse)
          {
              try
              {
                  TracingService.Trace("Trying to get value of: {0}", optionSetsProperty.Name);
  
                  OptionSetValue skillLevel = (OptionSetValue)optionSetsProperty.GetValue(fse);
                  TracingService.Trace("Value equals: {0}", skillLevel);
  
              }
              catch (Exception ex)
              {
                  TracingService.Trace("An error occured: {0}", ex.Message);
                  Exception inner = ex;
                  while (inner != null)
                  {
                      TracingService.Trace(inner.Message);
                      inner = inner.InnerException;
                  }
                  throw new InvalidOperationException(String.Format("Cannot get value of skill level from property: {0}", optionSetsProperty.Name), ex);
              }
          }
  </code></pre>
  
  <p>Here's the Log details:</p>
  
  <pre><code>Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Method not found: 'System.Object System.Reflection.PropertyInfo.GetValue(System.Object)'.Detail: 
  &lt;OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts"&gt;
    &lt;ErrorCode&gt;-2147220891&lt;/ErrorCode&gt;
    &lt;ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic"&gt;
      &lt;KeyValuePairOfstringanyType&gt;
        &lt;d2p1:key&gt;OperationStatus&lt;/d2p1:key&gt;
        &lt;d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string"&gt;0&lt;/d2p1:value&gt;
      &lt;/KeyValuePairOfstringanyType&gt;
    &lt;/ErrorDetails&gt;
    &lt;Message&gt;Method not found: 'System.Object System.Reflection.PropertyInfo.GetValue(System.Object)'.&lt;/Message&gt;
    &lt;Timestamp&gt;2014-09-11T12:58:09.2941554Z&lt;/Timestamp&gt;
    &lt;InnerFault i:nil="true" /&gt;
    &lt;TraceText&gt;
  
  [OC.CSSFieldService: OC.CSSFieldService.ServiceActivity.MyPlugin]
  [424ad2a7-ea29-e411-be7f-00155d0aa109: OC.CSSFieldService.ServiceActivity.MyPlugin: Create of equipment]
  FSE object type: OC.Data.Equipment
  Resolving ResourceGroup on property: oc_ExpeCommHyper
  
  &lt;/TraceText&gt;
  &lt;/OrganizationServiceFault&gt;
  </code></pre>
  
  <p>As you can see even the tracing line "Trying to get value of" is not working. The exception is not caught... I don't know what to do. Any thoughts?</p>