我正在使用OutArgument创建一个WF程序。当我尝试访问Dictionary上的键时,我得到一个KeyNotFoundException并且该进程终止。我创建了一个失败的进程转储,下面是CLR线程堆栈。我可以在Main方法框架上看到四个本地人。
如何确定主框架上哪个本地具有对正在访问的字典的引用?我是否必须检查所有当地人或是否可以从上面的框架中确定?
0:000> !clrstack -a
OS Thread Id: 0xf20 (0)
Child SP IP Call Site
0032ebc8 7742019d [HelperMethodFrame: 0032ebc8]
0032ec84 7123f326 System.Collections.Generic.Dictionary`2[[System.__Canon, mscorlib],[System.__Canon, mscorlib]].get_Item(System.__Canon)
PARAMETERS:
this = <no data>
key = <no data>
LOCALS:
<no data>
<no data>
0032ec90 00210235 UserInArgument.Program.Main(System.String[])
PARAMETERS:
args (0x0032ecec) = 0x023823dc
LOCALS:
0x0032ece8 = 0x0244a8fc
0x0032ece4 = 0x0248ba2c
0x0032ece0 = 0x023824dc
0x0032ecdc = 0x0244a8fc
0x0032ecd8 = 0x02465fb8
答案 0 :(得分:0)
使用以下过程,我能够看到作为Dictionary的键传递的字符串:
1 - 转储托管函数堆栈
003ced0c 7123f326 (MethodDesc 7053d6c8 System.Collections.Generic.Dictionary`2[[System.__Canon, mscorlib],[System.__Canon, mscorlib]].get_Item(System.__Canon))
003ced18 00200136 (MethodDesc 001837d8 +0xe6 UserInArgument.Program.Main(System.String[]))
2 - 转储词典索引器的IL
ilAddr = 012d2050
IL_0000: nop
IL_0001: newobj UserInArgument.WorkflowInCode::.ctor
IL_0006: stloc.1
IL_0007: ldloc.1
IL_0008: ldstr "Dblk"
IL_000d: call class [System.Activities]System.Activities.InArgum甥휄Έ섛撮 횰Έ辋撩았ϯ::op_Implicit
IL_0012: callvirt UserInArgument.WorkflowInCode::set_FirstName
IL_0017: nop
IL_0018: ldloc.1
IL_0019: ldstr "third sample"
IL_001e: call class [System.Activities]System.Activities.InArgum甥휄Έ섛撮 횰Έ辋撩았ϯ::op_Implicit
IL_0023: callvirt UserInArgument.WorkflowInCode::set_SecondName
IL_0028: nop
IL_0029: ldloc.1
IL_002a: call System.Activities.WorkflowInvoker::Invoke
IL_002f: pop
IL_0030: newobj UserInArgument.Workflow::.ctor
IL_0035: call System.Activities.WorkflowInvoker::Invoke
IL_003a: stloc.0
IL_003b: ldloc.0
IL_003c: ldstr "OutMessage_Should_Fail"
IL_0041: callvirt class [mscorlib]System.Collections.Generic.IDictio甥휄Έ섛撮 횰Έ辋撩았ϯ::get_Item
IL_0046: call System.Console::WriteLine
IL_004b: nop
IL_004c: ret
ldstr函数将新对象引用推送到字符串文字 - &gt; ldstr&#34; OutMessage_Should_Fail&#34;。