{"record":{"id":"e20558a4754e3e29","repo":"JeffreySu/WeiXinMPSDK","slug":"irequestmessageminiprogrampage-workmessageentityenlightener","errorCode":null,"errorMessage":"微信企业号不支持 IRequestMessageMiniProgramPage 响应类型","messagePattern":"微信企业号不支持 IRequestMessageMiniProgramPage 响应类型","errorType":"exception","errorClass":"MessageHandlerException","httpStatus":null,"severity":"error","filePath":"src/Senparc.Weixin.Work/Senparc.Weixin.Work/MessageHandlers/WorkMessageEntityEnlightener.cs","lineNumber":106,"sourceCode":"\n        public override IResponseMessageTransfer_Customer_Service NewResponseMessageTransfer_Customer_Service()\n        {\n            throw new MessageHandlerException(\"微信企业号不支持 IResponseMessageTransfer_Customer_Service 响应类型\");\n        }\n\n        public override IResponseMessageVideo NewResponseMessageVideo()\n        {\n            return new ResponseMessageVideo();\n        }\n\n        public override IResponseMessageVoice NewResponseMessageVoice()\n        {\n            return new ResponseMessageVoice();\n        }\n\n        public override IRequestMessageMiniProgramPage NewRequestMessageMiniProgramPage()\n        {\n            throw new MessageHandlerException(\"微信企业号不支持 IRequestMessageMiniProgramPage 响应类型\");\n        }\n    }\n}\n\n\n","sourceCodeStart":88,"sourceCodeEnd":112,"githubUrl":"https://github.com/JeffreySu/WeiXinMPSDK/blob/be573f6f94bdbf718dd5f6cdecb137fbc7ff651e/src/Senparc.Weixin.Work/Senparc.Weixin.Work/MessageHandlers/WorkMessageEntityEnlightener.cs#L88-L112","documentation":"NewRequestMessageMiniProgramPage() throws MessageHandlerException because WeChat Work requests never produce a mini-program-page request message; this request entity type is unsupported in the Work platform, so the enlightener refuses to instantiate it.","triggerScenarios":"Calling NewRequestMessageMiniProgramPage() on the Work message handler, e.g. in generic code that enumerates all request entity types regardless of platform.","commonSituations":"Shared test helpers or reflection-driven handler scaffolding that instantiates request entities for both MP and Work; mini-program page messages only occur on the MP platform.","solutions":["Do not instantiate IRequestMessageMiniProgramPage in Work handlers; use the supported Work request entity types.","Gate the call behind a platform check so mini-program request entities are only created in MP handlers.","If you need mini-program handling under Work, handle it via the appropriate Work event/message types instead."],"exampleFix":"// before\nvar req = messageHandler.NewRequestMessageMiniProgramPage();\n// after\nvar req = messageHandler.NewRequestMessageText(); // supported Work request type","handlingStrategy":"type-guard","validationCode":"if (requestMessage is IRequestMessageMiniProgramPage) { /* MP only — never valid in Work */ }","typeGuard":"bool IsMiniProgramRequest(IWorkRequestMessageBase req) => req is Senparc.Weixin.Work.RequestMessageMiniProgramPage; // will simply never match; guard before instantiating","tryCatchPattern":"try\n{\n    req = messageHandler.NewRequestMessageMiniProgramPage();\n}\ncatch (MessageHandlerException)\n{\n    req = messageHandler.NewRequestMessageText();\n}","preventionTips":["Only instantiate mini-program request entities in MP message handlers.","Avoid reflection-based loops that create every request entity type regardless of platform."],"tags":["weixin-work","message-handler","unsupported-request-type"],"backgroundTag":"unsupported-operation","analyzedSha":"be573f6f94bdbf718dd5f6cdecb137fbc7ff651e","analyzedAt":"2026-09-12T10:01:50.733Z","contentChangedAt":"2026-09-12T10:01:50.733Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}