C# Reflection exception Method not found

2021-03-29 08:28

阅读:365

标签: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


评论


亲,登录后才可以留言!