为什么这段反汇编代码不能在C#中编译?

为什么这段反汇编代码不能在C#中编译?,c#,module,cil,reflector,C#,Module,Cil,Reflector,我从CIL到C#转换器(.Net reflector)恢复了以下类。不幸的是,VS2010不会编译它。你知道我该怎么做吗 using System; using System.IO; using System.Reflection; internal class <Module> { static <Module>() { IPLRes.ExeDirectory = new FileInfo(Assembly.GetExecutingAss

我从CIL到C#转换器(.Net reflector)恢复了以下类。不幸的是,VS2010不会编译它。你知道我该怎么做吗

using System;
using System.IO;
using System.Reflection;
internal class <Module>
{
    static <Module>()
    {
        IPLRes.ExeDirectory = new FileInfo(Assembly.GetExecutingAssembly>>().Location).DirectoryName;
        AppDomain expr_1E = AppDomain.CurrentDomain;
        expr_1E.AssemblyResolve += new ResolveEventHandler(expr_1E.AssemblyNotFound);
        IPLRes.LogDirectory = IPLRes.ExeDirectory + "\\log";
        IPLMsg.Log("Loader", "Application starting...");
    }
    public static Assembly AssemblyNotFound(object A_0, ResolveEventArgs A_1)
    {
        string text = A_1.Name;
        text = text.Remove(text.IndexOf(","));
        text = IPLRes.ExeDirectory + "\\bin35\\" + text + ".dll";
        return Assembly.LoadFile(text);
    }
    [STAThread]
    public static void IPLMain(string[] A_0)
    {
        if (A_0.Length >= 1)
        {
            IPLRes.BatchMode = A_0[0].Contains("batch");
        }
        if (!IPLRes.BatchMode)
        {
            IPLRes.ShowSplash("ipl_splash.png");
        }
        string[] array = new string[]
        {
            "-X:FullFrames", 
            "-X:Python30", 
            "-c", 
            IPLRes.GetString("ipl_entrypoint35.py")
        };
        IPLMsg.Log("Loader", "Starting main interpreter");
        IPLRes.MainInterpreter = new IronPythonHost();
        if (IPLRes.MainInterpreter.Run(array) != 0)
        {
            array = new string[]
            {
                "-c", 
                IPLRes.GetString("ipl_crash.py")
            };
            IPLMsg.Log("Loader", "Starting crash handler interpreter");
            IPLRes.CrashInterpreter = new IronPythonHost();
            IPLRes.CrashInterpreter.Run(array);
        }
        IPLMsg.Log("Loader", "Application shutting down.");
        IPLMsg.DumpLogFile();
    }
}
使用系统;
使用System.IO;
运用系统反思;
内部类
{
静态()
{
IPLRes.exeditory=新文件信息(Assembly.GetExecutingAssembly>>().Location).DirectoryName;
AppDomain expr_1E=AppDomain.CurrentDomain;
expr_1E.AssemblyResolve+=新的ResolveEventHandler(expr_1E.AssemblyNotFound);
IPLRes.LogDirectory=IPLRes.exeditory+“\\log”;
Log(“加载程序”,“应用程序启动…”);
}
公共静态程序集AssemblyNotFound(对象A_0,ResolveEventArgs A_1)
{
字符串文本=A_1.Name;
text=text.Remove(text.IndexOf(“,”);
text=IPLRes.exeditory+“\\bin35\\”+text+“.dll”;
返回Assembly.LoadFile(文本);
}
[状态线程]
公共静态void IPLMain(字符串[]A_0)
{
如果(A_0.Length>=1)
{
IPLRes.BatchMode=A_0[0]。包含(“批”);
}
如果(!IPLRes.BatchMode)
{
IPLRes.ShowSplash(“ipl_splash.png”);
}
字符串[]数组=新字符串[]
{
“-X:全帧”,
“-X:Python30”,
“-c”,
GetString(“ipl_entrypoint35.py”)
};
日志(“加载程序”,“启动主解释器”);
IPLRes.main解释器=新的IronPythonHost();
if(IPLRes.mainprogrator.Run(数组)!=0)
{
数组=新字符串[]
{
“-c”,
GetString(“ipl_crash.py”)
};
Log(“加载程序”,“启动崩溃处理程序解释器”);
IPLRes.crashinterpter=新的IronPythonHost();
IPLRes.crashinterpter.Run(数组);
}
Log(“加载程序”,“应用程序关闭”);
IPLMsg.DumpLogFile();
}
}

这是一个模块初始值设定项,C#不支持

您可以将其放在Main()中。

您需要将Main()的其余部分移动到一个单独的方法,以便在添加
AssemblyResolve
处理程序后可以对其进行JIT。

这意味着编译器在尝试编译非法命名的类
时会犹豫。看看SLaks的答案,看看这里到底发生了什么。考虑添加特定的编译器错误消息——即使没有它也能看到问题,它增加了背景和参考。谢谢兄弟们。