Files
Fishing2Server/Main/Program.cs
2026-01-18 16:37:46 +08:00

34 lines
1.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// ================================================================================
// Fantasy.Net 服务器应用程序入口
// ================================================================================
// 本文件是 Fantasy.Net 分布式游戏服务器的主入口点
//
// 初始化流程:
// 1. 强制加载引用程序集,触发 ModuleInitializer 执行
// 2. 配置日志基础设施NLog
// 3. 启动 Fantasy.Net 框架
// ================================================================================
using System;
using Fantasy;
using NBF.ConfigTable;
try
{
// 初始化引用的程序集,确保 ModuleInitializer 执行
// .NET 采用延迟加载机制 - 仅当类型被引用时才加载程序集
// 通过访问 AssemblyMarker 强制加载程序集并调用 ModuleInitializer
// 注意Native AOT 不存在延迟加载问题,所有程序集在编译时打包
AssemblyHelper.Initialize();
ConfigTableHelper.Initialize();
// 配置 NLog 日志基础设施
var logger = new Fantasy.NLog("Server");
// 使用 NLog 日志系统启动 Fantasy.Net 框架
await Fantasy.Platform.Net.Entry.Start(logger);
}
catch (Exception ex)
{
Console.Error.WriteLine($"服务器初始化过程中发生致命错误:{ex}");
Environment.Exit(1);
}