{"record":{"id":"25cd6c2ffa2001e4","repo":"EllanJiang/GameFramework","slug":"not-supported-service-type-0","errorCode":null,"errorMessage":"Not supported service type '{0}'.","messagePattern":"Not supported service type '(.+?)'\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Network/NetworkManager.cs","lineNumber":254,"sourceCode":"\n            if (HasNetworkChannel(name))\n            {\n                throw new GameFrameworkException(Utility.Text.Format(\"Already exist network channel '{0}'.\", name ?? string.Empty));\n            }\n\n            NetworkChannelBase networkChannel = null;\n            switch (serviceType)\n            {\n                case ServiceType.Tcp:\n                    networkChannel = new TcpNetworkChannel(name, networkChannelHelper);\n                    break;\n\n                case ServiceType.TcpWithSyncReceive:\n                    networkChannel = new TcpWithSyncReceiveNetworkChannel(name, networkChannelHelper);\n                    break;\n\n                default:\n                    throw new GameFrameworkException(Utility.Text.Format(\"Not supported service type '{0}'.\", serviceType));\n            }\n\n            networkChannel.NetworkChannelConnected += OnNetworkChannelConnected;\n            networkChannel.NetworkChannelClosed += OnNetworkChannelClosed;\n            networkChannel.NetworkChannelMissHeartBeat += OnNetworkChannelMissHeartBeat;\n            networkChannel.NetworkChannelError += OnNetworkChannelError;\n            networkChannel.NetworkChannelCustomError += OnNetworkChannelCustomError;\n            m_NetworkChannels.Add(name, networkChannel);\n            return networkChannel;\n        }\n\n        /// <summary>\n        /// 销毁网络频道。\n        /// </summary>\n        /// <param name=\"name\">网络频道名称。</param>\n        /// <returns>是否销毁网络频道成功。</returns>\n        public bool DestroyNetworkChannel(string name)\n        {","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Network/NetworkManager.cs#L236-L272","documentation":"CreateNetworkChannel switches on the ServiceType enum and only supports Tcp and TcpWithSyncReceive in this codebase. Any other ServiceType value falls into the default case and throws this formatted error. It usually indicates an enum value from a newer/other version or an uninitialized field.","triggerScenarios":"Passing a ServiceType value not handled by the switch (e.g. a UDP value added in another fork), or a default(ServiceType)/0 value that maps to an unsupported enum member.","commonSituations":"Upgrading GameFramework while custom code uses an enum member from a different branch; serializing ServiceType to config and reading back an out-of-range number; forgetting which service types the runtime supports.","solutions":["Use ServiceType.Tcp or ServiceType.TcpWithSyncReceive","Add the missing case to the switch in CreateNetworkChannel if you extended ServiceType with your own channel implementation","Validate the enum value before calling; guard against uninitialized/default enum fields"],"exampleFix":"// before\nvar channel = networkManager.CreateNetworkChannel(name, ServiceType.Udp, helper);\n// after\nvar channel = networkManager.CreateNetworkChannel(name, ServiceType.TcpWithSyncReceive, helper);","handlingStrategy":"validation","validationCode":"if (serviceType != ServiceType.Tcp && serviceType != ServiceType.TcpWithSyncReceive)\n    throw new InvalidOperationException($\"Unsupported ServiceType: {serviceType}\");\nvar channel = networkManager.CreateNetworkChannel(name, serviceType, helper);","typeGuard":"bool IsSupported(ServiceType t) => t == ServiceType.Tcp || t == ServiceType.TcpWithSyncReceive;","tryCatchPattern":"try { var channel = networkManager.CreateNetworkChannel(name, serviceType, helper); }\ncatch (GameFrameworkException ex) { Log.Error(\"Unsupported service type: {0}\", ex.Message); }","preventionTips":["Enum.IsDefined check on values read from config","Don't serialize raw enum numbers across versions","Keep ServiceType usage in sync with the runtime's switch cases"],"tags":["network","enum","unsupported-value","gameframework"],"backgroundTag":"invalid-enum-value","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}