[英]MissingMethodException: Method not found
Just not able to understand why I am getting this error. 只是不明白为什么我会收到此错误。 I have code and trying to implement indexer: 我有代码并尝试实现索引器:
public class BOCollection<TKey, TValue>
{
IDictionary<TKey, TValue> _privateDictionary = new Dictionary<TKey, TValue>();
public TValue this[TKey key]
{
get{return _privateDictionary[key];}
set{_privateDictionary[key] = value;}
}
//Dictionary Methods
//Other methods
}
There is no compile time error, but getting run time error: 没有编译时错误,但出现运行时错误:
Method not found: 'System.Collections.Generic.Dictionary`2 NGC.BO.Base.BOBaseClass.get_Child()'. 找不到方法:“ System.Collections.Generic.Dictionary`2 NGC.BO.Base.BOBaseClass.get_Child()”。
Your indexer is fine. 您的索引器很好。 Seems that your collection have some object(s) that are missing required implementation of Child
property. 似乎您的集合中有一些对象缺少Child
属性的必需实现。
So another solution to this could be, because I experienced this. 因此,对此的另一种解决方案可能是,因为我经历了这种情况。 I have a project depending on a few other projects. 我有一个项目取决于其他几个项目。 The main project also had reference to one of the other projects - how ever - it did not use it. 主项目还引用了其他项目之一-但是-没有使用它。
So when I deleted the reference in the main object, the problem disappeared. 因此,当我删除主要对象中的引用时,问题消失了。 I have a feeling the reason is that the main object is built last and therefor it overwrites the newly built otherproject.dll with it's own otherproject.dll ... because it is not being used. 我有一种感觉,原因是主对象是最后构建的,因此它用自己的otherproject.dll覆盖了新构建的otherproject.dll ...因为未使用它。
So my suggestion is: Go over your references and check if it is being used in the project or not. 因此,我的建议是:查阅您的参考文献,检查它是否正在项目中使用。 If it isn't - remove it all together. 如果不是,请全部删除。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.