JeffreySu/WeiXinMPSDK · error · MessageHandlerException
微信企业号不支持 IResponseMessageMusic 响应类型
Error message
微信企业号不支持 IResponseMessageMusic 响应类型
What it means
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).
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.
Example fix
// before var resp = requestMessageHandler.CreateResponseMessage<IResponseMessageMusic>(); // after var resp = requestMessageHandler.CreateResponseMessage<IResponseMessageText>(); resp.Content = "点击收听:<a href=\"https://...\">音乐</a>";
Defensive patterns
Strategy: fallback
Validate before calling
IWorkResponseMessageBase resp;
if (musicWanted)
{
resp = handler.CreateResponseMessage<IResponseMessageText>(); // music not supported in Work
} Type guard
bool IsWorkHandler(MessageHandler<DefaultWorkMessageContext> h) => h is Senparc.Weixin.Work.MessageHandlers.WorkMessageHandler<DefaultWorkMessageContext>;
Try / catch
try
{
resp = handler.CreateResponseMessage<IResponseMessageMusic>();
}
catch (MessageHandlerException)
{
resp = handler.CreateResponseMessage<IResponseMessageText>();
} Prevention
- 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.
When it happens
Trigger: Calling NewResponseMessageMusic() on the Work message handler entity enlightener, typically inside DefaultResponseMessage or a message handler method to reply with a music message.
Common situations: Porting Official Account code that replies with music messages to WeChat Work; copying MP message-handler examples into a WorkMessageHandler.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- 微信企业号不支持 IResponseMessageMpNews 响应类型
- 微信企业号不支持 IResponseMessageTransfer_Customer_Service 响应类型
- 微信企业号不支持 IRequestMessageMiniProgramPage 响应类型
- 微信公众号不支持 IResponseMessageImage 响应类型
- 微信公众号不支持 IResponseMessageMpNews 响应类型
AI-assisted analysis of JeffreySu/WeiXinMPSDK@be573f6f94 (2026-09-12).
Data as JSON: /api/errors/ae2722391a4d1c44.
Report an issue: GitHub.
Appendix: source
Thrown at src/Senparc.Weixin.Work/Senparc.Weixin.Work/MessageHandlers/WorkMessageEntityEnlightener.cs:76
public override IRequestMessageVoice NewRequestMessageVoice()
{
return new RequestMessageVoice();
}
public override IResponseMessageImage NewResponseMessageImage()
{
return new ResponseMessageImage();
}
public override IResponseMessageMpNews NewResponseMessageMpNews()
{
throw new MessageHandlerException("微信企业号不支持 IResponseMessageMpNews 响应类型");
}
public override IResponseMessageMusic NewResponseMessageMusic()
{
throw new MessageHandlerException("微信企业号不支持 IResponseMessageMusic 响应类型");
}
public override IResponseMessageNews NewResponseMessageNews()
{
return new ResponseMessageNews();
}
public override IResponseMessageText NewResponseMessageText()
{
return new ResponseMessageText();
}
public override IResponseMessageTransfer_Customer_Service NewResponseMessageTransfer_Customer_Service()
{
throw new MessageHandlerException("微信企业号不支持 IResponseMessageTransfer_Customer_Service 响应类型");
}
public override IResponseMessageVideo NewResponseMessageVideo()View on GitHub (pinned to be573f6f94)