JeffreySu/WeiXinMPSDK · error · WeixinMenuException
菜单类型无法处理:
Error message
菜单类型无法处理:{rootButton.type} What it means
GetButtonGroup switches on the button's type string; when a bottom-level button has a type the library does not recognize (or an unsupported new Weixin type), it throws WeixinMenuException '菜单类型无法处理:{type}'.
Solutions
- Upgrade Senparc.Weixin.MP to the latest version so new menu types are supported
- Inspect the message for the unrecognized type and remove or fix that button in the menu
- Catch WeixinMenuException and log the offending type for diagnosis
Example fix
// package reference // before: Senparc.Weixin.MP 6.x (no miniprogram type support) // after: dotnet add package Senparc.Weixin.MP --version latest
Defensive patterns
Strategy: validation
Validate before calling
var supported = new[]{"click","view","scancode_push","scancode_waitmsg","pic_sysphoto","pic_photo_or_album","pic_weixin","location_select","view_limited","miniprogram"};
if (!supported.Contains(menuJson.button.First().type?.ToLower()))
throw new NotSupportedException($"Unsupported menu type: {menuJson.button.First().type}"); Try / catch
try
{
var menu = CommonApi.GetMenu(appId);
}
catch (WeixinMenuException ex) when (ex.Message.StartsWith("菜单类型无法处理"))
{
logger.LogWarning(ex, "Unhandled menu type encountered; upgrade SDK or fix menu");
} Prevention
- Keep Senparc.Weixin.MP upgraded to the latest release
- Check Weixin release notes for new menu types before adopting them
- Validate button types against the SDK version you run
- Log the offending type from the exception message
When it happens
Trigger: A menu contains a button whose type value is not handled by the installed library version (e.g. newer Weixin types added after this library version was released) or an unexpected/garbage type value.
Common situations: Weixin introduces a new menu type while the project pins an old Senparc.Weixin SDK version; manually edited menu JSON with a typo in type.
Related errors
AI-assisted analysis of JeffreySu/WeiXinMPSDK@be573f6f94 (2026-09-12).
Data as JSON: /api/errors/87e8ca51aa42eb69.
Report an issue: GitHub.
Appendix: source
Thrown at src/Senparc.Weixin.MP/Senparc.Weixin.MP/CommonAPIs/Menu/CommonApi.Menu.Common.cs:246
{
name = rootButton.name,
article_id = rootButton.article_id,
type = rootButton.type
});
}
else if (rootButton.type.Equals("ARTICLE_VIEW_LIMITED", StringComparison.OrdinalIgnoreCase))
{
//article_view_limited 按钮
buttonGroup.button.Add(new SingleArticleViewLimitedButton()
{
name = rootButton.name,
article_id = rootButton.article_id,
type = rootButton.type
});
}
else
{
throw new WeixinMenuException("菜单类型无法处理:" + rootButton.type);
}
}
//else if (availableSubButton < 2)
//{
// throw new WeixinMenuException("子菜单至少需要填写2个!");
//}
else
{
//底部二级菜单
var subButton = new SubButton(rootButton.name);
buttonGroup.button.Add(subButton);
foreach (var subSubButton in rootButton.sub_button)
{
if (subSubButton == null || string.IsNullOrEmpty(subSubButton.name))
{
continue; //没有设置菜单
}View on GitHub (pinned to be573f6f94)