看到可疑部分是:
Dim iLGenerator As ILGenerator = methodInfoBody.GetILGenerator
Dim str As String = Me.a(A_0, A_1)
Dim label As Label = iLGenerator.DefineLabel
iLGenerator.Emit(OpCodes.Ldarg_0)
iLGenerator.Emit(OpCodes.Ldfld, field)
iLGenerator.Emit(OpCodes.Brtrue, label)
iLGenerator.Emit(OpCodes.Ldarg_0)
iLGenerator.Emit(OpCodes.Ldarg_0)
iLGenerator.Emit(OpCodes.Callvirt, GetType(InterfaceBase).GetMethod("get_Connection", (BindingFlags.NonPublic Or (BindingFlags.Public Or BindingFlags.Instance))))
iLGenerator.Emit(OpCodes.Ldstr, str)
iLGenerator.Emit(OpCodes.Newobj, GetType(QueryCommand).GetConstructor(New Type() { GetType(QueryConnection), GetType(String) }))
iLGenerator.Emit(OpCodes.Stfld, field)
iLGenerator.MarkLabel(label)
Dim method As MethodInfo = GetType(QueryCommand).GetMethod("Execute", (BindingFlags.Public Or BindingFlags.Instance))
Dim meth As MethodInfo = GetType(QueryCommand).GetMethod("SetParameter", (BindingFlags.Public Or BindingFlags.Instance))
Dim info4 As MethodInfo = GetType(QueryCommand).GetMethod("GetParameter", (BindingFlags.Public Or BindingFlags.Instance))
Dim k As Integer
For k = 0 To parameters.Length - 1
Dim info5 As ParameterInfo = parameters(k)
iLGenerator.Emit(OpCodes.Ldarg_0)
iLGenerator.Emit(OpCodes.Ldfld, field)
iLGenerator.Emit(OpCodes.Ldstr, info5.Name)
iLGenerator.Emit(OpCodes.Ldtoken, info5.ParameterType)
If info5.ParameterType.IsValueType Then
iLGenerator.Emit(OpCodes.Ldarg, CInt((k + 1)))
iLGenerator.Emit(OpCodes.Box, info5.ParameterType)
Else
iLGenerator.Emit(OpCodes.Ldarg, CInt((k + 1)))
End If
iLGenerator.Emit(OpCodes.Callvirt, meth)
Next k
iLGenerator.Emit(OpCodes.Ldarg_0)
iLGenerator.Emit(OpCodes.Ldfld, field)
iLGenerator.Emit(OpCodes.Callvirt, method)
Dim m As Integer
For m = 0 To parameters.Length - 1
Dim info6 As ParameterInfo = parameters(m)
If (info6.IsOut OrElse info6.ParameterType.IsByRef) Then
iLGenerator.Emit(OpCodes.Ldarg_0)
iLGenerator.Emit(OpCodes.Ldfld, field)
iLGenerator.Emit(OpCodes.Ldstr, info6.Name)
iLGenerator.Emit(OpCodes.Callvirt, info4)
If info6.ParameterType.IsValueType Then
iLGenerator.Emit(OpCodes.Unbox, info6.ParameterType)
iLGenerator.Emit(OpCodes.Ldobj, A_1.ReturnType)
iLGenerator.Emit(OpCodes.Starg, CInt((m + 1)))
Else
iLGenerator.Emit(OpCodes.Starg, CInt((m + 1)))
End If
End If
Next m
If (Not A_1.ReturnType Is GetType(Void)) Then
iLGenerator.Emit(OpCodes.Ldarg_0)
iLGenerator.Emit(OpCodes.Ldfld, field)
iLGenerator.Emit(OpCodes.Callvirt, GetType(QueryCommand).GetMethod("get_ReturnValue", (BindingFlags.Public Or BindingFlags.Instance)))
If (Not A_1.ReturnType Is GetType(Object)) Then
If A_1.ReturnType.IsValueType Then
iLGenerator.Emit(OpCodes.Unbox, A_1.ReturnType)
iLGenerator.Emit(OpCodes.Ldobj, A_1.ReturnType)
Else
iLGenerator.Emit(OpCodes.Castclass, A_1.ReturnType)
End If
End If
End If
iLGenerator.Emit(OpCodes.Ret)
Me.e.DefineMethodOverride(methodInfoBody, A_1)