{"record":{"id":"d44f51a5c73b1f75","repo":"JeffreySu/WeiXinMPSDK","slug":"iresponsemessagevoice","errorCode":null,"errorMessage":"微信公众号不支持 IResponseMessageVoice 响应类型","messagePattern":"微信公众号不支持 IResponseMessageVoice 响应类型","errorType":"exception","errorClass":"MessageHandlerException","httpStatus":null,"severity":"error","filePath":"src/Senparc.Weixin.WxOpen/src/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen/MessageHandlers/WxOpenMessageEntityEnlightener.cs","lineNumber":100,"sourceCode":"        public override IResponseMessageText NewResponseMessageText()\n        {\n            return new Senparc.Weixin.MP.Entities.ResponseMessageText();\n            //throw new MessageHandlerException(\"微信公众号不支持 IResponseMessageText 响应类型\");\n        }\n\n        public override IResponseMessageTransfer_Customer_Service NewResponseMessageTransfer_Customer_Service()\n        {\n            return new ResponseMessageTransfer_Customer_Service();\n        }\n\n        public override IResponseMessageVideo NewResponseMessageVideo()\n        {\n            throw new MessageHandlerException(\"微信公众号不支持 IResponseMessageVideo 响应类型\");\n        }\n\n        public override IResponseMessageVoice NewResponseMessageVoice()\n        {\n            throw new MessageHandlerException(\"微信公众号不支持 IResponseMessageVoice 响应类型\");\n        }\n\n        public override IRequestMessageMiniProgramPage NewRequestMessageMiniProgramPage()\n        {\n            return new RequestMessageMiniProgramPage();\n        }\n\n    }\n}\n","sourceCodeStart":82,"sourceCodeEnd":110,"githubUrl":"https://github.com/JeffreySu/WeiXinMPSDK/blob/be573f6f94bdbf718dd5f6cdecb137fbc7ff651e/src/Senparc.Weixin.WxOpen/src/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen/MessageHandlers/WxOpenMessageEntityEnlightener.cs#L82-L110","documentation":"WxOpenMessageEntityEnlightener.NewResponseMessageVoice unconditionally throws MessageHandlerException. Voice replies are 公众号-only; the WxOpen factory deliberately rejects building them for Mini Program message handling.","triggerScenarios":"Calling NewResponseMessageVoice() on the WxOpen enlightener, e.g. a WxOpen On* handler trying to return a voice response or shared reply code that emits voice messages.","commonSituations":"Copy-pasting MP voice-reply code into WxOpen handlers; generic reply builders handling both MP and WxOpen without a platform branch.","solutions":["Reply with ResponseMessageText or transfer to customer service in WxOpen.","Remove the voice-reply branch from the WxOpen handler.","Send voice content through MP customer-service messages if it must be delivered."],"exampleFix":"// before\nvar voice = enlightener.NewResponseMessageVoice();\n// after\nvar reply = enlightener.NewResponseMessageText();\nreply.Content = \"请在公众号中收听语音内容\";","handlingStrategy":"validation","validationCode":"if (platform == Platform.WxOpen && replyKind == ReplyKind.Voice)\n    replyKind = ReplyKind.Text; // voice replies unsupported in WxOpen","typeGuard":"static bool IsVoiceResponse(IResponseMessageBase r) => r is IResponseMessageVoice; // invalid in WxOpen","tryCatchPattern":"try\n{\n    var voice = enlightener.NewResponseMessageVoice();\n}\ncatch (MessageHandlerException)\n{\n    reply = enlightener.NewResponseMessageText();\n}","preventionTips":["Restrict voice replies to MP handlers.","Use text replies or customer-service transfer as fallbacks in WxOpen.","Keep platform-specific reply builders separate to avoid accidental reuse."],"tags":["wxopen","message-handler","unsupported-response-type","voice"],"backgroundTag":"unsupported-operation","analyzedSha":"be573f6f94bdbf718dd5f6cdecb137fbc7ff651e","analyzedAt":"2026-09-12T10:01:50.733Z","contentChangedAt":"2026-09-12T10:01:50.733Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}