关于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的配置文件 问题解决方法: 传统 ...
随机推荐
- ZYNQ笔记(1):PL端——led灯
ZYNQ分为PS和PL,此博客实际上是FPGA中一个完整的FPGA工程的创建. PS:处理系统 (Processing System) 即ARM的Soc部分 PL:可编程逻辑(Programable ...
- Harbor 开机自启遇到的问题
Harbor 是一个企业级的 Docker 私有仓库项目,它本身由多个 Docker Containers 组成,通过 docker-compose 管理 containers 之间的依赖关系. 安装 ...
- CDN 访问控制的那些事
网络已经成为生活中必不可少的一部分,无论是清早手机翻看的新闻八卦,还是公交地铁里刷的停不下来的短视频,又或是你闲逛的购物网站,热追的电视剧,都与 CDN 有着密不可分的联系.无论你在互联网上做什么,或 ...
- robotframework_接口自动化
我们在使用rebotframework的时候,不只是能做UI自动化,接口自动化也是可以的. 那么这里就整理一下rebotframework_接口自动化的应用: 一.编写接口测试 由上图可知,该接口如下 ...
- Python进阶(九)----json模块, pickle模块, os模块,sys模块,hashlib模块
Python进阶----json模块, pickle模块, os模块,sys模块,hashlib模块 一丶序列化模块 什么是序列化: 将一种数据结构,转换成一个特殊的序列(特殊字符串,用于网络传输 ...
- JQuery+Bootstrap 自定义全屏Loading插件
/** * 自定义Loading插件 * @param {Object} config * { * content[加载显示文本], * time[自动关闭等待时间(ms)] * } * @param ...
- Oracle 12c数据库的安装
Oracle一路走来,不知不觉中已经到了12c,最近要用这个新版本了,从oracle的官网上注册了个用户,下载了win版本64位的先试一下. (1)下载安装包 a. 到官网进行下载需要先注册一个Ora ...
- php与mysql交互 面向过程
1.建立.关闭与MySQL服务器的连接 1)连接指定的mysql服务器 $mysqli_connect=@mysqli_connect($host, $user, $password,$databas ...
- python系列:二、Urllib库的高级用法
1.设置Headers 有些网站不会同意程序直接用上面的方式进行访问,如果识别有问题,那么站点根本不会响应,所以为了完全模拟浏览器的工作,我们需要设置一些Headers 的属性. 打开我们的浏览器,调 ...
- JS 小工具 MYSQL WHERE IN条件 去掉换行符(列转行)
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8&quo ...