惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
M
MIT News - Artificial intelligence
MyScale Blog
MyScale Blog
博客园_首页
G
Google Developers Blog
博客园 - 【当耐特】
美团技术团队
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
Vercel News
Vercel News
小众软件
小众软件
博客园 - 司徒正美
雷峰网
雷峰网
T
Tailwind CSS Blog
V
V2EX
博客园 - 三生石上(FineUI控件)
F
Fortinet All Blogs
罗磊的独立博客
量子位
P
Proofpoint News Feed
Microsoft Azure Blog
Microsoft Azure Blog
月光博客
月光博客
A
About on SuperTechFans
Hugging Face - Blog
Hugging Face - Blog

博客园 - Zhenway

Azure SignalR支持replication啦 Azure SignalR总览 定制json序列化 今天折腾这么一个正则 docfx组件介绍--YamlSerialization docfx daylybuild docfx开源啦 docfx组件介绍--MarkdownLite docfx预热中 合并批量请求 一个简单的Linq to TreeNode 在finally中调用一个需要await的方法 当泛型方法推断,扩展方法遇到泛型类型in/out时。。。 4.5你太黑了,不带这么玩TypeForwardedTo的 一个非常简单的反射加速方案 加载时预防并发执行 又发现一个msdn的坑 又发现个.net framework的坑 sql server死锁神器
踩到一个Emit的坑,留个纪念
Zhenway · 2013-11-13 · via 博客园 - Zhenway

重现代码:

var dmFoo = new DynamicMethod("Foo", typeof(void), Type.EmptyTypes);
var ilFoo = dmFoo.GetILGenerator();
//...
var label = ilFoo.DefineLabel();
//...
var dmBar = new DynamicMethod("Bar", typeof(void), Type.EmptyTypes);
var ilBar = dmBar.GetILGenerator();
//...
ilBar.MarkLabel(label);

报错信息为:

...NullReferenceException...
at System.Reflection.Emit.ILGenerator.MarkLabel(Label loc)
at ...(your code)

很明显代码中把ilFoo的Label试图放到ilBar里去,这时显然应该抛出一个ArgumentException,而Framework却傻乎乎的抛出了个NullReferenceException,害得我白到网上找了两个小时,却没发现什么类似的报错,最后才发现其实是一个参数弄错了