JeffreySu/WeiXinMPSDK · error · MessageHandlerException
微信公众号不支持 IRequestMessageVoice 请求类型
Error message
微信公众号不支持 IRequestMessageVoice 请求类型
What it means
WxOpenMessageEntityEnlightener.NewRequestMessageVoice unconditionally throws MessageHandlerException. Voice request messages are a 公众号 (MP) feature not supported by the WxOpen Mini Program message pipeline, so the factory deliberately refuses to construct the entity.
Solutions
- Route voice messages to an MP MessageHandler instead of the WxOpen handler.
- Check requestMessage type before requesting the voice entity from the enlightener.
- Verify the WeChat callback URL/token configuration so MP messages do not reach the WxOpen endpoint.
Example fix
// before
var voiceMsg = enlightener.NewRequestMessageVoice();
// after
if (requestMessage is IRequestMessageVoice voiceMsg) { /* only valid in MP handler */ } Defensive patterns
Strategy: type-guard
Validate before calling
if (requestMessage is IRequestMessageVoice) { /* use MP MessageHandler */ return; } Type guard
static bool IsVoiceRequest(IRequestMessage m) => m is IRequestMessageVoice;
Try / catch
try
{
var voiceMsg = enlightener.NewRequestMessageVoice();
}
catch (MessageHandlerException)
{
// voice unsupported in WxOpen; route to MP handler or default reply
} Prevention
- Verify token/server configuration so 公众号 messages are not routed to the 小程序 endpoint.
- Check message type before calling any New* factory method.
- Keep a mapping table of supported WxOpen message types in your handler code.
When it happens
Trigger: Calling NewRequestMessageVoice() on the WxOpen enlightener, e.g. when the WxOpenMessageHandler receives a voice-type message XML or third-party code requests a voice request entity.
Common situations: Sharing one message-handling codebase between MP and WxOpen; tests exercising all IRequestMessageVoice paths; misconfigured callback URL routing 公众号 messages to a WxOpen handler.
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
- 微信公众号不支持 IRequestMessageShortVideo 请求类型
- 微信公众号不支持 IRequestMessageVideo 请求类型
- 微信公众号不支持 IResponseMessageVoice 响应类型
- MsgType: 在RequestMessageFactory中没有对应的处理程序!
- 微信公众号不支持 IRequestMessageFile 请求类型
AI-assisted analysis of JeffreySu/WeiXinMPSDK@be573f6f94 (2026-09-12).
Data as JSON: /api/errors/8d0a1e44880cd051.
Report an issue: GitHub.
Appendix: source
Thrown at src/Senparc.Weixin.WxOpen/src/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen/MessageHandlers/WxOpenMessageEntityEnlightener.cs:59
public override IRequestMessageShortVideo NewRequestMessageShortVideo()
{
throw new MessageHandlerException("微信公众号不支持 IRequestMessageShortVideo 请求类型");
}
public override IRequestMessageText NewRequestMessageText()
{
return new RequestMessageText();
}
public override IRequestMessageVideo NewRequestMessageVideo()
{
throw new MessageHandlerException("微信公众号不支持 IRequestMessageVideo 请求类型");
}
public override IRequestMessageVoice NewRequestMessageVoice()
{
throw new MessageHandlerException("微信公众号不支持 IRequestMessageVoice 请求类型");
}
public override IResponseMessageImage NewResponseMessageImage()
{
throw new MessageHandlerException("微信公众号不支持 IResponseMessageImage 响应类型");
}
public override IResponseMessageMpNews NewResponseMessageMpNews()
{
throw new MessageHandlerException("微信公众号不支持 IResponseMessageMpNews 响应类型");
}
public override IResponseMessageMusic NewResponseMessageMusic()
{
throw new MessageHandlerException("微信公众号不支持 IResponseMessageMusic 响应类型");
}
public override IResponseMessageNews NewResponseMessageNews()View on GitHub (pinned to be573f6f94)