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

推荐订阅源

Blog — PlanetScale
Blog — PlanetScale
爱范儿
爱范儿
MongoDB | Blog
MongoDB | Blog
腾讯CDC
aimingoo的专栏
aimingoo的专栏
月光博客
月光博客
Engineering at Meta
Engineering at Meta
C
Check Point Blog
N
Netflix TechBlog - Medium
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LangChain Blog
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
Microsoft Security Blog
Microsoft Security Blog
GbyAI
GbyAI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
The Blog of Author Tim Ferriss
Last Week in AI
Last Week in AI
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
WordPress大学
WordPress大学
博客园 - 司徒正美

博客园 - 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,害得我白到网上找了两个小时,却没发现什么类似的报错,最后才发现其实是一个参数弄错了