title: What does System.Reflection.TargetException: Non-static method requires a target. mean?
body: <p>In my application I receive the functionCode value from somewhere and need to reflect the appropriate class. I tried to reflect the appropriate type According to <a href="https://stackoverflow.com/a/28324161/764809">this</a>  solution. but it doesn't work for me. I can not use GetField() method because I'm working on a PCL project. Therefore I tried these lines of code:</p>
  
  <pre><code>AssemblyName name = new AssemblyName("MyLibrary");
  var type = Assembly.Load(name);
  type.DefinedTypes.FirstOrDefault(x =&gt;
  x.GetDeclaredProperty("functionCode") != null &amp;&amp;
   (byte)x.GetDeclaredProperty("functionCode").GetValue(null) == val);
  </code></pre>
  
  <p>It does not work too. It throws System.Reflection.TargetException: Non-static method requires a target.</p>