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

推荐订阅源

J
Java Code Geeks
美团技术团队
Recent Announcements
Recent Announcements
B
Blog
GbyAI
GbyAI
雷峰网
雷峰网
博客园_首页
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Tailwind CSS Blog
M
MIT News - Artificial intelligence
V
V2EX
人人都是产品经理
人人都是产品经理
爱范儿
爱范儿
L
LangChain Blog
Microsoft Security Blog
Microsoft Security Blog
宝玉的分享
宝玉的分享
A
About on SuperTechFans
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
U
Unit 42
Hugging Face - Blog
Hugging Face - Blog
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
Last Week in AI
Last Week in AI
aimingoo的专栏
aimingoo的专栏

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