コード例 #1
0
        public void GenerateExecutable()
        {
            GenerateMainMethod();

            DummyType = DummyTypeBuilder.CreateType();

            ThisAssemblyBuilder.SetEntryPoint(MainMethodBuilder, PEFileKinds.ConsoleApplication);
            ThisAssemblyBuilder.Save(ExecutableFileName);

            Compiled = true;
        }
コード例 #2
0
        public ILBuilder(string codeFilePath)
        {
            Compiled = false;

            CodeFilePath       = codeFilePath;
            ExecutableFileName = GetExecutableFileName(codeFilePath);

            ThisAssemblyName = new AssemblyName(
                Guid.NewGuid().ToString("N"));
            ThisAssemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(
                ThisAssemblyName, AssemblyBuilderAccess.RunAndSave);
            ThisModuleBuilder = ThisAssemblyBuilder.DefineDynamicModule(
                ThisAssemblyName.Name, ExecutableFileName);
            DummyTypeBuilder = ThisModuleBuilder.DefineType(
                Constants.DummyTypeName, TypeAttributes.Public | TypeAttributes.Class);
            MainMethodBuilder = DummyTypeBuilder.DefineMethod(
                Constants.MainMethodName, MethodAttributes.Public | MethodAttributes.Static,
                typeof(int), new Type[] { typeof(string[]) });
            MainMethodILGenerator = MainMethodBuilder.GetILGenerator();
        }