10.1 Application startup

本文主要介绍C#应用程序启动相关内容。应用启动时执行环境调用入口点方法Main,它有特定签名,可返回int值,也可带形式参数并遵循约束。C#支持方法重载,但一个程序中符合入口点条件的Main方法只能有一个。此外,入口点访问不受声明限制。
10.1 Application startup
Application startup occurs when the execution environment calls a designated
method, which is referred to
as the application’s entry point. This entry point method is always named
Main, and shall have one of the
following signatures:
static void Main() {.}
static void Main(string[] args) {.}
static int Main() {.}
static int Main(string[] args) {.}
As shown, the entry point may optionally return an int value. This return
value is used in application
termination (§10.2).
The entry point may optionally have one formal parameter, and this formal
parameter may have any name. If
such a parameter is declared, it must obey the following constraints:
. The implementation shall ensure that the value of this parameter is not
null.
. Let args be the name of the parameter. If the length of the array
designated by args is greater than
zero, the array members args[0] through args[args.Length-1], inclusive,
must refer to strings,
called application parameters, which are given implementation-defined
values by the host environment
prior to application startup. The intent is to supply to the application
information determined prior to
application startup from elsewhere in the hosted environment. If the host
environment is not capable of
supplying strings with letters in both uppercase and lowercase, the
implementation shall ensure that the
strings are received in lowercase. [Note: On systems supporting a command
line, application parameters
correspond to what are generally known as command-line arguments. end note]
Since C# supports method overloading, a class or struct may contain
multiple definitions of some method,
provided each has a different signature. However, within a single program,
no class or struct shall contain
more than one method called Main whose definition qualifies it to be used
as an application entry point.
Other overloaded versions of Main are permitted, however, provided they
have more than one parameter, or
their only parameter is other than type string[].
An application can be made up of multiple classes or structs. It is
possible for more than one of these classes
or structs to contain a method called Main whose definition qualifies it to
be used as an application entry
point. In such cases, one of these Main methods must be chosen as the entry
point so that application startup
can occur. This choice of an entry point is beyond the scope of this
specification.no mechanism for
specifying or determining an entry point is provided.
In C#, every method must be defined as a member of a class or struct.
Ordinarily, the declared accessibility
(§10.5.1) of a method is determined by the access modifiers (§17.2.3)
specified in its declaration, and
similarly the declared accessibility of a type is determined by the access
modifiers specified in its
declaration. In order for a given method of a given type to be callable,
both the type and the member must be
accessible. However, the application entry point is a special case.
Specifically, the execution environment
can access the application’s entry point regardless of its declared
accessibility and regardless of the declared
accessibility of its enclosing type declarations.
In all other respects, entry point methods behave like those that are not
entry points.
25-Oct-2025 00:53:08.425 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server.服务器版本: Apache Tomcat/10.1.48 25-Oct-2025 00:53:08.441 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 服务器构建: Oct 10 2025 14:33:56 UTC 25-Oct-2025 00:53:08.455 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 服务器版本号: 10.1.48.0 25-Oct-2025 00:53:08.455 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 操作系统名称: Windows 11 25-Oct-2025 00:53:08.457 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS.版本: 10.0 25-Oct-2025 00:53:08.457 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 架构: amd64 25-Oct-2025 00:53:08.457 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Java 环境变量: C:\Program Files\Java\jdk-22 25-Oct-2025 00:53:08.457 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Java虚拟机版本: 22.0.1+8-16 25-Oct-2025 00:53:08.457 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM.供应商: Oracle Corporation 25-Oct-2025 00:53:08.457 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: D:\tomcat\apache-tomcat-10.1.48-windows-x64\apache-tomcat-10.1.48 25-Oct-2025 00:53:08.457 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: D:\tomcat\apache-tomcat-10.1.48-windows-x64\apache-tomcat-10.1.48 25-Oct-2025 00:53:08.560 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djava.util.logging.config.file=D:\tomcat\apache-tomcat-10.1.48-windows-x64\apache-tomcat-10.1.48\conf\logging.properties 25-Oct-2025 00:53:08.561 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 25-Oct-2025 00:53:08.561 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djdk.tls.ephemeralDHKeySize=2048 25-Oct-2025 00:53:08.562 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources 25-Oct-2025 00:53:08.562 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Dsun.io.useCanonCaches=false 25-Oct-2025 00:53:08.562 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: --add-opens=java.base/java.lang=ALL-UNNAMED 25-Oct-2025 00:53:08.563 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: --add-opens=java.base/java.lang.reflect=ALL-UNNAMED 25-Oct-2025 00:53:08.563 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: --add-opens=java.base/java.io=ALL-UNNAMED 25-Oct-2025 00:53:08.563 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: --add-opens=java.base/java.util=ALL-UNNAMED 25-Oct-2025 00:53:08.563 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED 25-Oct-2025 00:53:08.563 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED 25-Oct-2025 00:53:08.563 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Dcatalina.base=D:\tomcat\apache-tomcat-10.1.48-windows-x64\apache-tomcat-10.1.48 25-Oct-2025 00:53:08.567 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Dcatalina.home=D:\tomcat\apache-tomcat-10.1.48-windows-x64\apache-tomcat-10.1.48 25-Oct-2025 00:53:08.567 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 命令行参数: -Djava.io.tmpdir=D:\tomcat\apache-tomcat-10.1.48-windows-x64\apache-tomcat-10.1.48\temp 25-Oct-2025 00:53:08.579 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent 使用APR版本[1.7.6]加载了基于APR的Apache Tomcat本机库[2.0.9]。 25-Oct-2025 00:53:08.595 信息 [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL成功初始化 [OpenSSL 3.5.0 8 Apr 2025] 25-Oct-2025 00:53:09.477 信息 [main] org.apache.coyote.AbstractProtocol.init 初始化协议处理器 ["http-nio-8080"] 25-Oct-2025 00:53:09.579 信息 [main] org.apache.catalina.startup.Catalina.load 服务器在[1862]毫秒内初始化 25-Oct-2025 00:53:09.729 信息 [main] org.apache.catalina.core.StandardService.startInternal 正在启动服务[Catalina] 25-Oct-2025 00:53:09.729 信息 [main] org.apache.catalina.core.StandardEngine.startInternal 正在启动 Servlet 引擎:[Apache Tomcat/10.1.48] 25-Oct-2025 00:53:09.745 信息 [main] org.apache.catalina.startup.HostConfig.deployDirectory 把web 应用程序部署到目录 [D:\tomcat\apache-tomcat-10.1.48-windows-x64\apache-tomcat-10.1.48\webapps\docs] 25-Oct-2025 00:53:10.786 信息 [main] org.apache.catalina.startup.HostConfig.deployDirectory Web应用程序目录[D:\tomcat\apache-tomcat-10.1.48-windows-x64\apache-tomcat-10.1.48\webapps\docs]的部署已在[1,022]毫秒内完成 25-Oct-2025 00:53:10.788 信息 [main] org.apache.catalina.startup.HostConfig.deployDirectory 把web 应用程序部署到目录 [D:\tomcat\apache-tomcat-10.1.48-windows-x64\apache-tomcat-10.1.48\webapps\examples] 25-Oct-2025 00:53:11.839 信息 [main] org.apache.catalina.startup.HostConfig.deployDirectory Web应用程序目录[D:\tomcat\apache-tomcat-10.1.48-windows-x64\apache-tomcat-10.1.48\webapps\examples]的部署已在[1,051]毫秒内完成 25-Oct-2025 00:53:11.839 信息 [main] org.apache.catalina.startup.HostConfig.deployDirectory 把web 应用程序部署到目录 [D:\tomcat\apache-tomcat-10.1.48-windows-x64\apache-tomcat-10.1.48\webapps\host-manager] 25-Oct-2025 00:53:11.960 信息 [main] org.apache.catalina.startup.HostConfig.deployDirectory Web应用程序目录[D:\tomcat\apache-tomcat-10.1.48-windows-x64\apache-tomcat-10.1.48\webapps\host-manager]的部署已在[111]毫秒内完成 25-Oct-2025 00:53:11.960 信息 [main] org.apache.catalina.startup.HostConfig.deployDirectory 把web 应用程序部署到目录 [D:\tomcat\apache-tomcat-10.1.48-windows-x64\apache-tomcat-10.1.48\webapps\manager] 25-Oct-2025 00:53:12.007 信息 [main] org.apache.catalina.startup.HostConfig.deployDirectory Web应用程序目录[D:\tomcat\apache-tomcat-10.1.48-windows-x64\apache-tomcat-10.1.48\webapps\manager]的部署已在[47]毫秒内完成 25-Oct-2025 00:53:12.007 信息 [main] org.apache.catalina.startup.HostConfig.deployDirectory 把web 应用程序部署到目录 [D:\tomcat\apache-tomcat-10.1.48-windows-x64\apache-tomcat-10.1.48\webapps\ROOT] 25-Oct-2025 00:53:12.060 信息 [main] org.apache.catalina.startup.HostConfig.deployDirectory Web应用程序目录[D:\tomcat\apache-tomcat-10.1.48-windows-x64\apache-tomcat-10.1.48\webapps\ROOT]的部署已在[53]毫秒内完成 25-Oct-2025 00:53:12.075 信息 [main] org.apache.coyote.AbstractProtocol.start 开始协议处理句柄["http-nio-8080"] 25-Oct-2025 00:53:12.195 信息 [main] org.apache.catalina.startup.Catalina.start [2608]毫秒后服务器启动 25-Oct-2025 00:53:58.979 信息 [main] org.apache.catalina.core.StandardServer.await 通过关闭端口接收到有效的关闭命令。正在停止服务器实例。 25-Oct-2025 00:53:58.984 信息 [main] org.apache.coyote.AbstractProtocol.pause 暂停ProtocolHandler["http-nio-8080"] 25-Oct-2025 00:53:59.004 信息 [main] org.apache.catalina.core.StandardService.stopInternal 正在停止服务[Catalina] 25-Oct-2025 00:53:59.071 信息 [main] org.apache.coyote.AbstractProtocol.stop 正在停止ProtocolHandler ["http-nio-8080"] 25-Oct-2025 00:53:59.079 信息 [main] org.apache.coyote.AbstractProtocol.destroy 正在销毁协议处理器 ["http-nio-8080"]
最新发布
10-26
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值