{"record":{"id":"5d98b8f48c385c0e","repo":"JeffreySu/WeiXinMPSDK","slug":"iresponsemessageimage","errorCode":null,"errorMessage":"微信公众号不支持 IResponseMessageImage 响应类型","messagePattern":"微信公众号不支持 IResponseMessageImage 响应类型","errorType":"exception","errorClass":"MessageHandlerException","httpStatus":null,"severity":"error","filePath":"src/Senparc.Weixin.WxOpen/src/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen/MessageHandlers/WxOpenMessageEntityEnlightener.cs","lineNumber":64,"sourceCode":"\n        public override IRequestMessageText NewRequestMessageText()\n        {\n            return new RequestMessageText();\n        }\n\n        public override IRequestMessageVideo NewRequestMessageVideo()\n        {\n            throw new MessageHandlerException(\"微信公众号不支持 IRequestMessageVideo 请求类型\");\n        }\n\n        public override IRequestMessageVoice NewRequestMessageVoice()\n        {\n            throw new MessageHandlerException(\"微信公众号不支持 IRequestMessageVoice 请求类型\");\n        }\n\n        public override IResponseMessageImage NewResponseMessageImage()\n        {\n            throw new MessageHandlerException(\"微信公众号不支持 IResponseMessageImage 响应类型\");\n        }\n\n        public override IResponseMessageMpNews NewResponseMessageMpNews()\n        {\n            throw new MessageHandlerException(\"微信公众号不支持 IResponseMessageMpNews 响应类型\");\n        }\n\n        public override IResponseMessageMusic NewResponseMessageMusic()\n        {\n            throw new MessageHandlerException(\"微信公众号不支持 IResponseMessageMusic 响应类型\");\n        }\n\n        public override IResponseMessageNews NewResponseMessageNews()\n        {\n            throw new MessageHandlerException(\"微信公众号不支持 IResponseMessageNews 响应类型\");\n        }\n\n        public override IResponseMessageText NewResponseMessageText()","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/JeffreySu/WeiXinMPSDK/blob/be573f6f94bdbf718dd5f6cdecb137fbc7ff651e/src/Senparc.Weixin.WxOpen/src/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen/MessageHandlers/WxOpenMessageEntityEnlightener.cs#L46-L82","documentation":"WxOpenMessageEntityEnlightener.NewResponseMessageImage unconditionally throws MessageHandlerException. Image response messages are a 公众号 (MP) reply type not supported by WxOpen, so the response-entity factory refuses to build one.","triggerScenarios":"Calling NewResponseMessageImage() on the WxOpen enlightener, typically when a WxOpen On* handler tries to return an image response or when code shares MP response-building logic with WxOpen.","commonSituations":"Copy-pasting MP OnTextRequest-style reply code into a WxOpen handler; building generic reply factories that produce image responses for all channels.","solutions":["Return a supported WxOpen response type instead, e.g. ResponseMessageText (see NewResponseMessageText).","Remove or branch the image-reply code path in the WxOpen handler.","Use customer-service messages (e.g. ResponseMessageTransfer_Customer_Service) to hand off to MP-side media replies."],"exampleFix":"// before\npublic override IResponseMessageImage OnXxxRequest(...) =>\n    requestMessageHandler.NewResponseMessageImage();\n// after\npublic override IResponseMessageBase OnXxxRequest(...) =>\n    requestMessageHandler.NewResponseMessageText(); // image replies unsupported in WxOpen","handlingStrategy":"validation","validationCode":"static readonly HashSet<Type> WxOpenResponseTypes = new()\n    { typeof(IResponseMessageText), typeof(IResponseMessageTransfer_Customer_Service) };\nif (!WxOpenResponseTypes.Contains(responseType)) return null; // avoid unsupported response types","typeGuard":"static bool IsSupportedWxOpenResponse<T>() where T : IResponseMessageBase =>\n    typeof(T) != typeof(IResponseMessageImage);","tryCatchPattern":"try\n{\n    var resp = enlightener.NewResponseMessageImage();\n}\ncatch (MessageHandlerException)\n{\n    resp = enlightener.NewResponseMessageText(); // fallback reply\n}","preventionTips":["Only reply with types the WxOpen enlightener supports (text, transfer_customer_service, miniprogrampage).","Never copy MP response-building code into WxOpen handlers without pruning unsupported types.","Review the enlightener source for the definitive list of supported response entities."],"tags":["wxopen","message-handler","unsupported-response-type","image"],"backgroundTag":"unsupported-operation","analyzedSha":"be573f6f94bdbf718dd5f6cdecb137fbc7ff651e","analyzedAt":"2026-09-12T10:01:50.733Z","contentChangedAt":"2026-09-12T10:01:50.733Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}