JeffreySu/WeiXinMPSDK · error · MessageHandlerException
微信企业号不支持 IRequestMessageLink 请求类型
Error message
微信企业号不支持 IRequestMessageLink 请求类型
What it means
WorkMessageEntityEnlightener.NewRequestMessageLink creates new entity instances for the message-handler pipeline; the Work (WeCom) platform has no link-type request message, so this method always throws MessageHandlerException instead of returning an entity. It is an intentional capability marker, not a runtime fault.
Solutions
- Remove code paths that create IRequestMessageLink entities for the Work platform — WeCom callbacks never produce link messages
- Guard the call with a platform check (RequestMsgType) or a try-catch for MessageHandlerException if running shared code
- Skip link-message handling in generic pipelines when the target platform is Work
Example fix
// before
var link = enlightener.NewRequestMessageLink();
// after
if (postModel.Platform != PlatformType.WeWork) { var link = enlightener.NewRequestMessageLink(); } Defensive patterns
Strategy: validation
Validate before calling
if (platform == PlatformType.WeWork) { throw new InvalidOperationException("Link messages are not supported on WeCom"); } var link = enlightener.NewRequestMessageLink(); Type guard
bool SupportsLinkMessages(MessageHandlerEntityEnlightener e) => !(e is WorkMessageEntityEnlightener);
Prevention
- Never call NewRequestMessageLink in code shared with the Work platform
- Check the target platform before invoking generic entity factories
- Treat link messages as MP-only in cross-platform pipelines
When it happens
Trigger: Code explicitly calls NewRequestMessageLink() on a Work message handler's enlightener, or generic message-handler code that iterates all message types (e.g. copying entities, reflection-based pipelines, shared MP code paths) invokes it.
Common situations: Porting MP (Official Account) handler code that references link messages to the Work platform; generic test harnesses instantiating every request entity type; reflection-driven code that enumerates NewRequestMessage* methods.
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
- 缓存策略 不支持枚举,请先检查 GetCapabilities()。
- ArgumentNullException (response is null)
- OpenHardwareCallbackCryptException (encrypt failed…
- 参数不能为空。
- ArgumentNullException (request is null)
AI-assisted analysis of JeffreySu/WeiXinMPSDK@be573f6f94 (2026-09-12).
Data as JSON: /api/errors/6573af12032359e2.
Report an issue: GitHub.
Appendix: source
Thrown at src/Senparc.Weixin.Work/Senparc.Weixin.Work/MessageHandlers/WorkMessageEntityEnlightener.cs:36
public override IRequestMessageEvent NewRequestMessageEvent()
{
return new RequestMessageEventBase();
}
public override IRequestMessageFile NewRequestMessageFile()
{
return new RequestMessageFile();
}
public override IRequestMessageImage NewRequestMessageImage()
{
return new RequestMessageImage();
}
public override IRequestMessageLink NewRequestMessageLink()
{
throw new MessageHandlerException("微信企业号不支持 IRequestMessageLink 请求类型");
}
public override IRequestMessageLocation NewRequestMessageLocation()
{
return new RequestMessageLocation();
}
public override IRequestMessageShortVideo NewRequestMessageShortVideo()
{
return new RequestMessageShortVideo();
}
public override IRequestMessageText NewRequestMessageText()
{
return new RequestMessageText();
}
public override IRequestMessageVideo NewRequestMessageVideo()View on GitHub (pinned to be573f6f94)