码迷,mamicode.com
首页 > Windows程序 > 详细

C# Reflection exception Method not found

时间:2018-07-13 17:34:23      阅读:262      评论:0      收藏:0      [点我收藏+]

标签:like   The   options   RKE   info   setvalue   indexer   ace   object   

C# Reflection exception Method not found

 

Ok I figured it out. The server has Microsft .NET 4.0 installed and I have .NET 4.5.

In the .NET 4.5 there‘s a new overload for PropertyInfo.GetValue method - it‘s PropertyInfo.GetValue(object obj) since in 4.0 there is only PropertyInfo.GetValue(object obj, object[] indexer)

I just had to replace:

OptionSetValue skillLevel = (OptionSetValue)optionSetsProperty.GetValue(fse); //4.5

with

OptionSetValue skillLevel = (OptionSetValue)optionSetsProperty.GetValue(fse, null); //4.0

worked like a charm!

C# Reflection exception Method not found

标签:like   The   options   RKE   info   setvalue   indexer   ace   object   

原文地址:https://www.cnblogs.com/youguess/p/9305879.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!