{"record":{"id":"ae2722391a4d1c44","repo":"JeffreySu/WeiXinMPSDK","slug":"iresponsemessagemusic","errorCode":null,"errorMessage":"微信企业号不支持 IResponseMessageMusic 响应类型","messagePattern":"微信企业号不支持 IResponseMessageMusic 响应类型","errorType":"exception","errorClass":"MessageHandlerException","httpStatus":null,"severity":"error","filePath":"src/Senparc.Weixin.Work/Senparc.Weixin.Work/MessageHandlers/WorkMessageEntityEnlightener.cs","lineNumber":76,"sourceCode":"\n        public override IRequestMessageVoice NewRequestMessageVoice()\n        {\n            return new RequestMessageVoice();\n        }\n\n        public override IResponseMessageImage NewResponseMessageImage()\n        {\n            return new ResponseMessageImage();\n        }\n\n        public override IResponseMessageMpNews NewResponseMessageMpNews()\n        {\n            throw new MessageHandlerException(\"微信企业号不支持 IResponseMessageMpNews 响应类型\");\n        }\n\n        public override IResponseMessageMusic NewResponseMessageMusic()\n        {\n            throw new MessageHandlerException(\"微信企业号不支持 IResponseMessageMusic 响应类型\");\n        }\n\n        public override IResponseMessageNews NewResponseMessageNews()\n        {\n            return new ResponseMessageNews();\n        }\n\n        public override IResponseMessageText NewResponseMessageText()\n        {\n            return new ResponseMessageText();\n        }\n\n        public override IResponseMessageTransfer_Customer_Service NewResponseMessageTransfer_Customer_Service()\n        {\n            throw new MessageHandlerException(\"微信企业号不支持 IResponseMessageTransfer_Customer_Service 响应类型\");\n        }\n\n        public override IResponseMessageVideo NewResponseMessageVideo()","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/JeffreySu/WeiXinMPSDK/blob/be573f6f94bdbf718dd5f6cdecb137fbc7ff651e/src/Senparc.Weixin.Work/Senparc.Weixin.Work/MessageHandlers/WorkMessageEntityEnlightener.cs#L58-L94","documentation":"The WeChat Work message handler does not support the Music response type. NewResponseMessageMusic() throws MessageHandlerException because WeChat Work's passive reply protocol has no music message type (unlike the Official Account platform).","triggerScenarios":"Calling NewResponseMessageMusic() on the Work message handler entity enlightener, typically inside DefaultResponseMessage or a message handler method to reply with a music message.","commonSituations":"Porting Official Account code that replies with music messages to WeChat Work; copying MP message-handler examples into a WorkMessageHandler.","solutions":["Use a supported Work response type (text/image/news/video/voice) instead of music.","Send music content as a text message containing a link, or push it proactively via the Work send-message API.","Remove the music branch from Work handlers and keep it only in MP handlers."],"exampleFix":"// before\nvar resp = requestMessageHandler.CreateResponseMessage<IResponseMessageMusic>();\n// after\nvar resp = requestMessageHandler.CreateResponseMessage<IResponseMessageText>();\nresp.Content = \"点击收听：<a href=\\\"https://...\\\">音乐</a>\";","handlingStrategy":"fallback","validationCode":"IWorkResponseMessageBase resp;\nif (musicWanted)\n{\n    resp = handler.CreateResponseMessage<IResponseMessageText>(); // music not supported in Work\n}","typeGuard":"bool IsWorkHandler(MessageHandler<DefaultWorkMessageContext> h) => h is Senparc.Weixin.Work.MessageHandlers.WorkMessageHandler<DefaultWorkMessageContext>;","tryCatchPattern":"try\n{\n    resp = handler.CreateResponseMessage<IResponseMessageMusic>();\n}\ncatch (MessageHandlerException)\n{\n    resp = handler.CreateResponseMessage<IResponseMessageText>();\n}","preventionTips":["Send music as a text message with a link in Work instead of a Music reply.","Review the enlightener's throw list (MpNews/Music/Transfer_Customer_Service/MiniProgramPage) when porting MP code."],"tags":["weixin-work","message-handler","unsupported-response-type"],"backgroundTag":"unsupported-operation","analyzedSha":"be573f6f94bdbf718dd5f6cdecb137fbc7ff651e","analyzedAt":"2026-09-12T10:01:50.733Z","contentChangedAt":"2026-09-12T10:01:50.733Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}