首页 > Windows开发 > 详细

C# Reflection exception Method not found

时间:2018-07-13 17:06:54      阅读:290      评论:0      收藏:0      [点我收藏+]

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!