关于System.MissingMethodException异常
什么是MissingMethodException
试图动态访问不存在的方法时引发的异常。
- 继承
说明
通常, 如果代码尝试访问不存在的类方法, 则会生成编译错误。 MissingMethodException旨在处理尝试动态访问未通过其强名称引用的程序集的已重命名或已删除方法的情况。 MissingMethodException当依赖程序集中的代码尝试访问已修改的程序集中缺少的方法时, 将引发。
HRESULT
MissingMethodException使用具有值0x80131513 的 HRESULT COR_E_MISSINGMETHOD。
示例
此示例演示当你尝试使用反射来调用不存在的方法并访问不存在的字段时会发生的情况。 应用程序通过捕获MissingMethodException、 MissingFieldException和MissingMemberException来恢复。
using namespace System;
using namespace System::Reflection; ref class App
{
}; int main()
{
try
{
// Attempt to call a static DoSomething method defined in the App class.
// However, because the App class does not define this method,
// a MissingMethodException is thrown.
App::typeid->InvokeMember("DoSomething", BindingFlags::Static |
BindingFlags::InvokeMethod, nullptr, nullptr, nullptr);
}
catch (MissingMethodException^ ex)
{
// Show the user that the DoSomething method cannot be called.
Console::WriteLine("Unable to call the DoSomething method: {0}",
ex->Message);
} try
{
// Attempt to access a static AField field defined in the App class.
// However, because the App class does not define this field,
// a MissingFieldException is thrown.
App::typeid->InvokeMember("AField", BindingFlags::Static |
BindingFlags::SetField, nullptr, nullptr, gcnew array<Object^>{});
}
catch (MissingFieldException^ ex)
{
// Show the user that the AField field cannot be accessed.
Console::WriteLine("Unable to access the AField field: {0}",
ex->Message);
} try
{
// Attempt to access a static AnotherField field defined in the App class.
// However, because the App class does not define this field,
// a MissingFieldException is thrown.
App::typeid->InvokeMember("AnotherField", BindingFlags::Static |
BindingFlags::GetField, nullptr, nullptr, nullptr);
}
catch (MissingMemberException^ ex)
{
// Notice that this code is catching MissingMemberException which is the
// base class of MissingMethodException and MissingFieldException.
// Show the user that the AnotherField field cannot be accessed.
Console::WriteLine("Unable to access the AnotherField field: {0}",
ex->Message);
}
}
// This code produces the following output.
//
// Unable to call the DoSomething method: Method 'App.DoSomething' not found.
// Unable to access the AField field: Field 'App.AField' not found.
// Unable to access the AnotherField field: Field 'App.AnotherField' not found.
关于System.MissingMethodException异常的更多相关文章
- 【EF框架异常】System.MissingMethodException:“找不到方法:“System.Data.Entity.ModelConfiguration.Configuration.PrimitivePropertyConfiguration
最近调试EF的时候遇到下面这个问题 System.MissingMethodException:“找不到方法:“System.Data.Entity.ModelConfiguration.Config ...
- 关于SubSonic3.0插件使用SqlQuery或Select查询时产生的System.NullReferenceException异常修复
早上在编写执行用例时,突然爆异常System.NullReferenceException: 未将对象引用设置到对象的实例 执行代码:
- 关于SubSonic3.0查询或更新时出现System.NullReferenceException异常的处理
在调试程序时,同事发现添加记录时,出现了System.NullReferenceException异常 DictBase dict = new DictBase(); dict.DictCode ...
- 关于System.TypeInitializationException异常
什么是System.TypeInitializationException 作为类初始值设定项引发的异常的包装器而引发的异常. 继承 Object Exception SystemException ...
- 异常详细信息: System.MissingMethodException: 无法创建抽象类。
asp.net mvc 在使用post向后端传送json数据时报异常,在路由配置中添加如下即可 public static void RegisterRoutes(RouteCollection ro ...
- .Net中使用com组件后发生System.ArithmeticException异常的解决办法(Message=算术运算中发生溢出或下溢。)
最近在开发一个.Net程序,其中涉及到对com组件的调用,或者第三方DLL调用, 在调用完以后如果使用一些小的测试程序继续运行,一切正常,但是在使用带有GUI的form程序,或者WPF程序中,继续执行 ...
- C# winform单元格的formatted值的类型错误 DataGridView中CheckBox列运行时候System.FormatException异常
在DataGridView手动添加了CheckBox列;在窗体Show的时候,遇到一个错误:错误如下: DataGridView中发生一下异常:System.FormatException:单元格的F ...
- [.Net]System.OutOfMemoryException异常
1. 一个异常情景 加载15000条等高线,平均每条线有400个点到三维球上,等待时间太长.而且可能会报内存异常. 2. 不错的分析 http://wenku.baidu.com/view/14471 ...
- log4j:WARN Please initialize the log4j system properly. 异常解决
log4j:WARN Please initialize the log4j system properly. 这个异常很少遇到,咋一看,原来是没有配置logger4j的配置文件 问题解决方法: 传统 ...
随机推荐
- 玩机之Honor_V10
作为一个热爱手机的Geek,自然是经历了很多的刷机和改装手机的经验,当然翻车的经验也是有的.一般来说的折腾手机都是在遇到某一版本使用以及各方面都比较稳定的时候才会选择让手机停留在哪一版本.下面我就来分 ...
- SAS学习笔记1
数据采样 简单随机抽样,从sashelp数据集中air数据文件中选取30个数 数据探索 数字特征的探索:均值.频数.最大值.最小值.众数.中位数.方差.标准差 数字分布的探索:是否服从正态分布 连续型 ...
- Python yield与实现(源码分析 转)
转自:https://www.cnblogs.com/coder2012/p/4990834.html
- mysql执行顺序与join连接
mysql加载顺序 手写顺序 SELECT DISTINCT <select list> FROM <left_table> join <join_type> JO ...
- phpdocmentor 生成php 开发文档(转载)
PHPDocumentor是一个用PHP写的工具,对于有规范注释的php程序,它能够快速生成具有相互参照,索引等功能的API文档.老的版本是phpdoc,从1.3.0开始,更名为phpDocument ...
- C# vb .net实现拉伸效果滤镜
在.net中,如何简单快捷地实现Photoshop滤镜组中的拉伸效果呢?答案是调用SharpImage!专业图像特效滤镜和合成类库.下面开始演示关键代码,您也可以在文末下载全部源码: 设置授权 第一步 ...
- Angular复习笔记5-指令
Angular复习笔记5-指令 在Angular中,指令是一个重要的概念,它作用在特定的DOM元素上,可以扩展这个元素的功能,为元素增加新的行为.本质上,组件可以被理解为一种带有视图的指令.组件继承自 ...
- 2019 世纪龙java面试笔试题 (含面试题解析)
本人5年开发经验.18年年底开始跑路找工作,在互联网寒冬下成功拿到阿里巴巴.今日头条.世纪龙等公司offer,岗位是Java后端开发,因为发展原因最终选择去了世纪龙,入职一年时间了,也成为了面试官 ...
- JavaScript之轮播图
(1)html <div class="box" id="box"> <ul class="uls" id="u ...
- 初识osquery
初识osquery osquery是一个由Facebook的开源用于对系统进行查询,监控以及分析的一款软件. osquery对其的说明如下: osquery将操作系统公开为高性能关系数据库.这允许您编 ...