首页
社区
课程
招聘
[求助]这段IL用reflector反编译出错。
2010-7-27 00:36 7394

[求助]这段IL用reflector反编译出错。

2010-7-27 00:36
7394
下面这段IL用reflector反编译出错。出来一个try catch when (?) ,不知什么原因。

IL代码
.method private static !!T Create__Instance__<([System.Windows.Forms]System.Windows.Forms.Form) .ctor T>(!!T Instance) cil managed
{
    .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor()
    .maxstack 4
    .locals init (
        [0] !!T local,
        [1] string str,
        [2] class [mscorlib]System.Reflection.TargetInvocationException exception,
        [3] string[] strArray)
    L_0000: ldarg.0
    L_0001: box !!T
    L_0006: brfalse.s L_001a
    L_0008: ldarga.s Instance
    L_000a: constrained !!T
    L_0010: callvirt instance bool [System.Windows.Forms]System.Windows.Forms.Control::get_IsDisposed()
    L_0015: brfalse L_00de
    L_001a: ldsfld class [mscorlib]System.Collections.Hashtable dsc60.My.MyProject/MyForms::m_FormBeingCreated
    L_001f: brfalse.s L_004d
    L_0021: ldsfld class [mscorlib]System.Collections.Hashtable dsc60.My.MyProject/MyForms::m_FormBeingCreated
    L_0026: ldtoken !!T
    L_002b: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
    L_0030: callvirt instance bool [mscorlib]System.Collections.Hashtable::ContainsKey(object)
    L_0035: brfalse.s L_0057
    L_0037: ldstr "WinForms_RecursiveFormCreate"
    L_003c: ldc.i4.0
    L_003d: newarr string
    L_0042: call string [Microsoft.VisualBasic]Microsoft.VisualBasic.CompilerServices.Utils::GetResourceString(string, string[])
    L_0047: newobj instance void [mscorlib]System.InvalidOperationException::.ctor(string)
    L_004c: throw
    L_004d: newobj instance void [mscorlib]System.Collections.Hashtable::.ctor()
    L_0052: stsfld class [mscorlib]System.Collections.Hashtable dsc60.My.MyProject/MyForms::m_FormBeingCreated
    L_0057: ldsfld class [mscorlib]System.Collections.Hashtable dsc60.My.MyProject/MyForms::m_FormBeingCreated
    L_005c: ldtoken !!T
    L_0061: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
    L_0066: ldnull
    L_0067: callvirt instance void [mscorlib]System.Collections.Hashtable::Add(object, object)
    L_006c: call !!0 [mscorlib]System.Activator::CreateInstance<!!T>()
    L_0071: stloc.0
    L_0072: leave.s L_00e0
    L_0074: isinst [mscorlib]System.Reflection.TargetInvocationException
    L_0079: dup
    L_007a: brtrue.s L_0080
    L_007c: pop
    L_007d: ldc.i4.0
    L_007e: br.s L_0096
    L_0080: dup
    L_0081: stloc.2
    L_0082: call void [Microsoft.VisualBasic]Microsoft.VisualBasic.CompilerServices.ProjectData::SetProjectError(class [mscorlib]System.Exception)
    L_0087: ldloc.2
    L_0088: callvirt instance class [mscorlib]System.Exception [mscorlib]System.Exception::get_InnerException()
    L_008d: ldnull
    L_008e: ceq
    L_0090: ldc.i4.0
    L_0091: ceq
    L_0093: ldc.i4.0
    L_0094: cgt.un
    L_0096: endfilter
    L_0098: pop
    L_0099: ldstr "WinForms_SeeInnerException"
    L_009e: ldc.i4.1
    L_009f: newarr string
    L_00a4: stloc.3
    L_00a5: ldloc.3
    L_00a6: ldc.i4.0
    L_00a7: ldloc.2
    L_00a8: callvirt instance class [mscorlib]System.Exception [mscorlib]System.Exception::get_InnerException()
    L_00ad: callvirt instance string [mscorlib]System.Exception::get_Message()
    L_00b2: stelem.ref
    L_00b3: ldloc.3
    L_00b4: call string [Microsoft.VisualBasic]Microsoft.VisualBasic.CompilerServices.Utils::GetResourceString(string, string[])
    L_00b9: stloc.1
    L_00ba: ldloc.1
    L_00bb: ldloc.2
    L_00bc: callvirt instance class [mscorlib]System.Exception [mscorlib]System.Exception::get_InnerException()
    L_00c1: newobj instance void [mscorlib]System.InvalidOperationException::.ctor(string, class [mscorlib]System.Exception)
    L_00c6: throw
    L_00c7: ldsfld class [mscorlib]System.Collections.Hashtable dsc60.My.MyProject/MyForms::m_FormBeingCreated
    L_00cc: ldtoken !!T
    L_00d1: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
    L_00d6: callvirt instance void [mscorlib]System.Collections.Hashtable::Remove(object)
    L_00db: endfinally
    L_00dc: br.s L_00e0
    L_00de: ldarg.0
    L_00df: ret
    L_00e0: ldloc.0
    L_00e1: ret
    .try L_006c to L_0074 filter L_0074 handler L_0098 to L_00c7
    .try L_006c to L_00c7 finally handler L_00c7 to L_00dc
}

//C#代码
[DebuggerHidden]
private static T Create__Instance__<T>(T Instance) where T: Form, new()
{
    T local;
    if ((Instance != null) && !Instance.IsDisposed)
    {
        return Instance;
    }
    if (m_FormBeingCreated != null)
    {
        if (m_FormBeingCreated.ContainsKey(typeof(T)))
        {
            throw new InvalidOperationException(Utils.GetResourceString("WinForms_RecursiveFormCreate", new string[0]));
        }
    }
    else
    {
        m_FormBeingCreated = new Hashtable();
    }
    m_FormBeingCreated.Add(typeof(T), null);
    try
    {
        local = Activator.CreateInstance<T>();
    }
  catch   when (?)    {
        TargetInvocationException exception;
        throw new InvalidOperationException(Utils.GetResourceString("WinForms_SeeInnerException", new string[] { exception.InnerException.Message }), exception.InnerException);
    }
    finally
    {
        m_FormBeingCreated.Remove(typeof(T));
    }
    return local;
}

[培训]《安卓高级研修班(网课)》月薪三万计划

收藏
点赞0
打赏
分享
最新回复 (2)
雪    币: 160
活跃值: (29)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
opensrc 1 2010-7-27 09:00
2
0
C# 不支持 try  filter   to 语句块。只有 try-catch-finally。所以。。。
你可以转成vb.net应该就可以了。
如果不影响功能的话,改成拦截所有异常并抛出的catch的C#就可以了。
雪    币: 211
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
sugengnn 2010-7-27 11:28
3
0
这确实是用VB.net写的程序,不过用VB.net反编译出来catch   when (?) 对应的是Catch obj1 As Object When (?)
还是带When (?),奇怪了
游客
登录 | 注册 方可回帖
返回