我需要在 IL 级别调试 dll,并阅读http://blogs.msdn.com/b/jmstall/archive/2004/10/03/237137.aspx我想用 il(d )asm。
拆卸通过,但重新组装失败
Assembled method Dapper.SqlMapper°UdtTypeHandler::Dapper.SqlMapper.ITypeHandler.SetValue
Assembled method Dapper.SqlMapper°TypeHandler`1::Dapper.SqlMapper.ITypeHandler.SetValue
Assembled method Dapper.SqlMapper°TypeHandler`1::Dapper.SqlMapper.ITypeHandler.Parse
Assembled method Dapper.SqlMapper°TypeHandler`1::.ctor
Assembled method Dapper.SqlMapper°Link`2::TryGet
W:\TimPrecast\ildasm\ppdbcore.il(71204) : error : Undeclared identifier IL_0016
W:\TimPrecast\ildasm\ppdbcore.il(71204) : error : syntax error at token ':' in: IL_0016: ldloc.s
***** FAILURE *****
然后我打开 ILSpy 中的 DLL 和记事本中生成的 IL 文件:
ILSpy:
IL_000a: stloc.1
IL_000b: ldloc.1
IL_000c: ldarg.1
IL_000d: ldloca.s found
IL_000f: call bool class Dapper.SqlMapper/Link`2<!TKey, !TValue>::TryGet(class Dapper.SqlMapper/Link`2<!0, !1>, !0, !1&)
IL_0014: stloc.s 4
IL_0016: ldloc.s 4
IL_0018: brfalse.s IL_0027
IL_001a: nop
IL_001b: ldarg.2
IL_001c: ldloc.2
IL_001d: stobj !TValue
IL_0022: ldc.i4.0
IL_0023: stloc.s 5
IL_0025: br.s IL_0051
ILDASM(第 71204 行是 IL_0016):
IL_000a: stloc.1
IL_000b: ldloc.1
IL_000c: ldarg.1
IL_000d: ldloca.s found
IL_000f: call bool class Dapper.SqlMapper/Link`2<!TKey,!TValue>::TryGet(class Dapper.SqlMapper/Link`2<!0,!1>,
!0,
!1&)
IL_0014: stloc.s
IL_0016: ldloc.s
IL_0018: brfalse.s IL_0027
IL_001a: nop
IL_001b: ldarg.2
IL_001c: ldloc.2
IL_001d: stobj !TValue
IL_0022: ldc.i4.0
IL_0023: stloc.s V_5
IL_0025: br.s IL_0051
似乎缺少 stloc.s 的索引。
ILDasm 帮助 -> 信息显示版本 4.0.30319.0。