JeffreySu/WeiXinMPSDK · error · MessageHandlerException
微信公众号不支持 IResponseMessageVoice 响应类型
Error message
微信公众号不支持 IResponseMessageVoice 响应类型
What it means
WxOpenMessageEntityEnlightener.NewResponseMessageVoice unconditionally throws MessageHandlerException. Voice replies are 公众号-only; the WxOpen factory deliberately rejects building them for Mini Program message handling.
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.
Example fix
// before var voice = enlightener.NewResponseMessageVoice(); // after var reply = enlightener.NewResponseMessageText(); reply.Content = "请在公众号中收听语音内容";
Defensive patterns
Strategy: validation
Validate before calling
if (platform == Platform.WxOpen && replyKind == ReplyKind.Voice)
replyKind = ReplyKind.Text; // voice replies unsupported in WxOpen Type guard
static bool IsVoiceResponse(IResponseMessageBase r) => r is IResponseMessageVoice; // invalid in WxOpen
Try / catch
try
{
var voice = enlightener.NewResponseMessageVoice();
}
catch (MessageHandlerException)
{
reply = enlightener.NewResponseMessageText();
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Copy-pasting MP voice-reply code into WxOpen handlers; generic reply builders handling both MP and WxOpen without a platform branch.
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
- 微信公众号不支持 IRequestMessageVoice 请求类型
- 微信公众号不支持 IResponseMessageImage 响应类型
- 微信公众号不支持 IResponseMessageMpNews 响应类型
- 微信公众号不支持 IResponseMessageMusic 响应类型
- 微信公众号不支持 IResponseMessageNews 响应类型
AI-assisted analysis of JeffreySu/WeiXinMPSDK@be573f6f94 (2026-09-12).
Data as JSON: /api/errors/d44f51a5c73b1f75.
Report an issue: GitHub.
Appendix: source
Thrown at src/Senparc.Weixin.WxOpen/src/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen/MessageHandlers/WxOpenMessageEntityEnlightener.cs:100
public override IResponseMessageText NewResponseMessageText()
{
return new Senparc.Weixin.MP.Entities.ResponseMessageText();
//throw new MessageHandlerException("微信公众号不支持 IResponseMessageText 响应类型");
}
public override IResponseMessageTransfer_Customer_Service NewResponseMessageTransfer_Customer_Service()
{
return new ResponseMessageTransfer_Customer_Service();
}
public override IResponseMessageVideo NewResponseMessageVideo()
{
throw new MessageHandlerException("微信公众号不支持 IResponseMessageVideo 响应类型");
}
public override IResponseMessageVoice NewResponseMessageVoice()
{
throw new MessageHandlerException("微信公众号不支持 IResponseMessageVoice 响应类型");
}
public override IRequestMessageMiniProgramPage NewRequestMessageMiniProgramPage()
{
return new RequestMessageMiniProgramPage();
}
}
}
View on GitHub (pinned to be573f6f94)