JeffreySu/WeiXinMPSDK · error · WeixinMenuException
菜单类型无法处理(二级菜单):
Error message
菜单类型无法处理(二级菜单):
What it means
When iterating second-level buttons, any sub_button whose type is not one of the handled values causes WeixinMenuException '菜单类型无法处理(二级菜单):{type}'. Note the message in the SOURCE concatenates the type, so the runtime message includes the offending value.
Solutions
- Upgrade Senparc.Weixin.MP to the newest release
- Identify the unsupported type from the exception message and correct or remove that sub_button in the menu definition
- Catch and log WeixinMenuException to capture the offending type
Defensive patterns
Strategy: validation
Validate before calling
foreach (var sub in btn.sub_button ?? Array.Empty<SubMenuJson>())
if (!supportedTypes.Contains(sub.type?.ToLower()))
throw new NotSupportedException($"Unsupported sub-button type: {sub.type}"); Try / catch
try
{
var menu = CommonApi.GetMenu(appId);
}
catch (WeixinMenuException ex) when (ex.Message.StartsWith("菜单类型无法处理(二级菜单)"))
{
logger.LogWarning(ex, "Unsupported second-level menu type");
} Prevention
- Upgrade the SDK before using newly announced Weixin menu types
- Whitelist known types in your menu editor UI
- Test menu parsing against menus fetched from production
- Capture the offending type from the exception message in logs
When it happens
Trigger: A menu's sub_button list contains a type unrecognized by the current SDK version, typically a Weixin menu type introduced after the installed library release.
Common situations: Outdated Senparc.Weixin.MP package encountering newer menu types; hand-edited or third-party-generated menu JSON with invalid type strings.
Related errors
AI-assisted analysis of JeffreySu/WeiXinMPSDK@be573f6f94 (2026-09-12).
Data as JSON: /api/errors/3a9e7f37ab6a8c93.
Report an issue: GitHub.
Appendix: source
Thrown at src/Senparc.Weixin.MP/Senparc.Weixin.MP/CommonAPIs/Menu/CommonApi.Menu.Common.cs:407
{
name = subSubButton.name,
article_id = subSubButton.article_id,
type = subSubButton.type
});
}
else if (subSubButton.type.Equals("ARTICLE_VIEW_LIMITED", StringComparison.OrdinalIgnoreCase))
{
//article_view_limited 按钮
subButton.sub_button.Add(new SingleArticleViewLimitedButton()
{
name = subSubButton.name,
article_id = subSubButton.article_id,
type = subSubButton.type
});
}
else
{
throw new WeixinMenuException("菜单类型无法处理(二级菜单):" + subSubButton.type);
}
}
}
}
}
/// <summary>
/// 根据微信返回的Json数据得到可用的GetMenuResult结果
/// </summary>
/// <param name="resultFull"></param>
/// <param name="buttonGroupBase">ButtonGroupBase的衍生类型,可以为ButtonGroup或ConditionalButtonGroup。返回的GetMenuResult中的menu属性即为此示例。</param>
/// <returns></returns>
public static GetMenuResult GetMenuFromJsonResult(GetMenuResultFull resultFull, ButtonGroupBase buttonGroupBase)
{
GetMenuResult result = null;
if (buttonGroupBase == null)
{
throw new ArgumentNullException("buttonGroupBase不可以为空!");View on GitHub (pinned to be573f6f94)