关于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的配置文件 问题解决方法: 传统 ...
随机推荐
- linux配置环境jdk
条件:将jdk安装好,如果没有安装请看这里:linux(Centos7系统)中安装JDK.Tomcat.Mysql 步骤如下: linux中,环境变量是在 /etc/profile 中修改文件 vi ...
- Python进阶----数据库的基础,关系型数据库与非关系型数据库(No SQL:not only sql),mysql数据库语言基础(增删改查,权限设定)
day37 一丶Python进阶----数据库的基础,mysql数据库语言基础(增删改查,权限设定) 什么是数据库: 简称:DataBase ---->DB 数据库即存放数据的仓库, ...
- php长连接应用
php长连接和短连接 2012-12-05 17:25 3529人阅读 评论(0) 收藏 举报 分类: 我的收藏(8) 什么是长连接,如果你没听说过,可以往下看! 长连接到底有什么用?我想你应该见 ...
- 数据仓库模型ETL架构(DWI/DWR/DM)
1.DWI DWI:数据湖.数据砥柱,一般存放在HDFS 数据仓库的基础数据来源,各种杂七杂八的数据 关键点:数据清洗.数据整合.异常处理.增量获取 ETL:E-数据抽取.数据清洁.格式转换,T-生成 ...
- 83.基于Vue SEO的四种方案(小结)
前言:众所周知,Vue SPA单页面应用对SEO不友好,当然也有相应的解决方案,下面列出几种最近研究和使用过的SEO方案,SRR和静态化基于Nuxt来说. 1.SSR服务器渲染:2.静态化:3.预渲染 ...
- Dockerfile 基本命令
1. 前言 Dockerfile 是用来构建自定义 Docker 镜像的文本文档.我们通过docker build 命令用于从Dockerfile 文件构建镜像.如果你要构建自定义镜像,Dockerf ...
- synchronized关键字的使用
synchronized关键字是java并发编程中常使用的同步锁,用于锁住方法或者代码块,锁代码块时可以是synchronized(this){}.synchronized(Object){}.syn ...
- 编程风格统一配置EditorConfig
EditorConfig 以纯原生无需任何插件支持 EditorConfig 代码风格配置的编辑器: Visual Studio 2017 开始添加了对 EditorConfig 的原生支持.Visu ...
- 基于 K8S 集群安装部署 istio-1.2.4
使用云平台可以为组织提供丰富的好处.然而,不可否认的是,采用云可能会给 DevOps 团队带来压力.开发人员必须使用微服务以满足应用的可移植性,同时运营商管理了极其庞大的混合和多云部署.Istio 允 ...
- index.jsp乱码问题的解决
我们在做java项目的时候,都会有个首页,一般就是index.jsp,然后在index.jsp中引入相关的文件,一般也是引入打包过后的相关资源文件. 当index.jsp上面的中文出现乱码的时候,就需 ...