Пример #1
0
        private void AddMainMethodCompilationRoot(EcmaModule module)
        {
            if (StartupCodeMain != null)
                throw new Exception("Multiple entrypoint modules");

            int entryPointToken = module.PEReader.PEHeaders.CorHeader.EntryPointTokenOrRelativeVirtualAddress;
            MethodDesc mainMethod = module.GetMethod(MetadataTokens.EntityHandle(entryPointToken));

            var owningType = module.GetGlobalModuleType();
            StartupCodeMain = new StartupCodeMainMethod(owningType, mainMethod);

            _rootProvider.AddCompilationRoot(StartupCodeMain, "Startup Code Main Method", "__managed__Main");
        }
Пример #2
0
        private void AddMainMethodCompilationRoot(EcmaModule module, IRootingServiceProvider rootProvider)
        {
            if (StartupCodeMain != null)
                throw new Exception("Multiple entrypoint modules");

            MethodDesc mainMethod = module.EntryPoint;
            if (mainMethod == null)
                throw new Exception("No managed entrypoint defined for executable module");

            var owningType = module.GetGlobalModuleType();
            StartupCodeMain = new StartupCodeMainMethod(owningType, mainMethod);

            rootProvider.AddCompilationRoot(StartupCodeMain, "Startup Code Main Method", "__managed__Main");
        }