JeffreySu/WeiXinMPSDK · error · MessageHandlerException
微信公众号不支持 IResponseMessageMpNews 响应类型
Error message
微信公众号不支持 IResponseMessageMpNews 响应类型
What it means
MpMessageEntityEnlightener.NewResponseMessageMpNews throws MessageHandlerException because the MP (公众号) channel does not support the mpnews response message type; the enlightener's factory method has no valid IResponseMessageMpNews implementation for this platform. Requesting an mpnews response entity from an MP message handler is by definition an invalid operation for WeChat official accounts.
Solutions
- Do not use IResponseMessageMpNews in MP handlers; reply with a supported type (Text, Image, Voice, Video, Music, News, Transfer_Customer_Service).
- Branch on platform: only build MpNews responses in contexts where the enlightener supports it (e.g. Senparc.Weixin.Work).
- If mpnews content is required for official accounts, use the 客服接口/群发 API (MassApi.SendMpNews) instead of passive message response.
- Guard any generic factory loop with a type check that skips/throws-before-use for MpNews on MP.
Example fix
// before
var response = enlightener.NewResponseMessageMpNews(); // throws on MP
// after
IResponseMessageBase response;
if (supportsMpNews) // e.g. Work platform
response = enlightener.NewResponseMessageMpNews();
else
response = new ResponseMessageText { Content = "fallback" }; Defensive patterns
Strategy: validation
Validate before calling
if (response is IResponseMessageMpNews)
throw new InvalidOperationException("MpNews responses are not supported on MP; use MassApi.SendMpNews instead."); Type guard
bool IsMpSupportedResponse(IResponseMessageBase r) =>
r is ResponseMessageText or ResponseMessageImage or ResponseMessageVoice
or ResponseMessageVideo or ResponseMessageMusic or ResponseMessageNews
or ResponseMessageTransfer_Customer_Service; Try / catch
try
{
response = enlightener.NewResponseMessageMpNews();
}
catch (MessageHandlerException ex) when (ex.Message.Contains("IResponseMessageMpNews"))
{
response = new ResponseMessageText { Content = "当前公众号暂不支持该消息类型" };
} Prevention
- Only use MpNews with Senparc.Weixin.Work (企业微信) contexts, never MP.
- For official-account news push, use MassApi (群发接口) or customer-service API.
- Centralize response construction in one factory that branches on platform.
- Avoid generic loops that instantiate every IResponseMessage type without filtering.
When it happens
Trigger: Code creates a response message via a MessageEntityEnlightener factory, e.g. calling NewResponseMessageMpNews() on an MP handler, or generic/copy-based response construction that iterates response types and includes MpNews for a 公众号 handler (common when code written for 微信企业号/开放平台 is reused on MP).
Common situations: Reusing handler/enlightener code across Senparc.Weixin.MP and Senparc.Weixin.Work (企业微信) where mpnews is supported only in Work; generic response-building helpers that don't branch on platform; accidentally selecting ResponseMessageMpNews when replying in a customer-service or passive-reply path.
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
- 微信公众号不支持 IRequestMessageMiniProgramPage 响应类型
- MsgType: 在RequestMessageFactory中没有对应的处理程序!
- 请使用异步方法 OnExecutingAsync()
- 请使用异步方法 OnExecutedAsync()
- 微信公众号不支持 IResponseMessageMpNews 响应类型
AI-assisted analysis of JeffreySu/WeiXinMPSDK@be573f6f94 (2026-09-12).
Data as JSON: /api/errors/17d7898bc553ae4c.
Report an issue: GitHub.
Appendix: source
Thrown at src/Senparc.Weixin.MP/Senparc.Weixin.MP/MessageHandlers/MpMessageEntityEnlightener.cs:76
public override IRequestMessageVideo NewRequestMessageVideo()
{
return new RequestMessageVideo();
}
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()
{
return new ResponseMessageMusic();
}
public override IResponseMessageNews NewResponseMessageNews()
{
return new ResponseMessageNews();
}
public override IResponseMessageText NewResponseMessageText()
{
return new ResponseMessageText();
}
public override IResponseMessageTransfer_Customer_Service NewResponseMessageTransfer_Customer_Service()View on GitHub (pinned to be573f6f94)