JeffreySu/WeiXinMPSDK · error · WeixinObsoleteException

Weixin.WxOpen.AdvancedAPIs.TemplateApi下调用同名接口!

Error message

Weixin.WxOpen.AdvancedAPIs.TemplateApi下调用同名接口!

What it means

TemplateApi.LibraryList in Senparc.Weixin.Open's WxaAPIs is a stub: it is marked [Obsolete] and immediately throws WeixinObsoleteException. The real implementation moved to the mini-program module Senparc.Weixin.WxOpen.AdvancedAPIs.TemplateApi.LibraryList.

Solutions

  1. Replace the call with Senparc.Weixin.WxOpen.AdvancedAPIs.TemplateApi.LibraryList(accessToken, offset, count, timeOut).
  2. Fully qualify or fix using directives so the WxOpen TemplateApi is imported, not the Open one.
  3. Remove references to the obsolete Open-module template APIs — they will always throw.

Example fix

// before
var list = Senparc.Weixin.Open.WxaAPIs.TemplateApi.LibraryList(accessToken, 0, 20);
// after
var list = Senparc.Weixin.WxOpen.AdvancedAPIs.TemplateApi.LibraryList(accessToken, 0, 20);
Defensive patterns

Strategy: validation

Validate before calling

var flags = typeof(Senparc.Weixin.Open.WxaAPIs.TemplateApi)
    .GetMethod(nameof(Senparc.Weixin.Open.WxaAPIs.TemplateApi.LibraryList))?
    .GetCustomAttributes(typeof(ObsoleteAttribute), false);
bool isObsoleteStub = flags != null && flags.Length > 0; // use WxOpen module instead

Try / catch

try { var r = Open.WxaAPIs.TemplateApi.LibraryList(token, 0, 20); }
catch (WeixinObsoleteException) { r = WxOpen.AdvancedAPIs.TemplateApi.LibraryList(token, 0, 20); }

Prevention

When it happens

Trigger: Calling the old Senparc.Weixin.Open.WxaAPIs.TemplateApi.LibraryList(accessToken, offset, count) — any call throws, there is no working code path.

Common situations: Upgrading Senparc.Weixin.Open where the method was gutted; old code samples referencing the Open-module TemplateApi; IDE auto-imports picking the wrong namespace (Open vs WxOpen).

Understand the failure class

Background: "is deprecated and will be removed" — deprecation warnings for old API names, keywords, and options, and how to migrate before the removal release — this error's family across 29 libraries.

Related errors


AI-assisted analysis of JeffreySu/WeiXinMPSDK@be573f6f94 (2026-09-12). Data as JSON: /api/errors/3246236fc64eab7a. Report an issue: GitHub.

Appendix: source

Thrown at src/Senparc.Weixin.Open/Senparc.Weixin.Open/WxaAPIs/Template/TemplateApi.cs:67

    public static class TemplateApi
    {
        #region 同步方法


        #region 模板快速设置

        /// <summary>
        /// 获取小程序模板库标题列表
        /// </summary>
        /// <param name="accessToken">接口调用凭证</param>
        /// <param name="offset">offset和count用于分页,表示从offset开始,拉取count条记录,offset从0开始,count最大为20。</param>
        /// <param name="count">offset和count用于分页,表示从offset开始,拉取count条记录,offset从0开始,count最大为20。</param>
        /// <param name="timeOut">请求超时时间</param>
        /// <returns></returns>
        [Obsolete("请在小程序模块Senparc.Weixin.WxOpen.AdvancedAPIs.TemplateApi下调用同名接口!")]
        public static WxJsonResult LibraryList(string accessToken, int offset, int count, int timeOut = Config.TIME_OUT)
        {
          throw new WeixinObsoleteException("Weixin.WxOpen.AdvancedAPIs.TemplateApi下调用同名接口!");
        }

        /// <summary>
        /// 获取模板库某个模板标题下关键词库
        /// </summary>
        /// <param name="accessToken">接口调用凭证</param>
        /// <param name="id">模板标题id,可通过接口获取,也可登录小程序后台查看获取</param>
        /// <param name="timeOut">请求超时时间</param>
        /// <returns></returns>
        [Obsolete("请在小程序模块Senparc.Weixin.WxOpen.AdvancedAPIs.TemplateApi下调用同名接口!")]
        public static WxJsonResult LibraryGet(string accessToken, string id, int timeOut = Config.TIME_OUT)
        {
            throw new WeixinObsoleteException("Weixin.WxOpen.AdvancedAPIs.TemplateApi下调用同名接口!");
        }


        /// <summary>
        /// 组合模板并添加至帐号下的个人模板库

View on GitHub (pinned to be573f6f94)