{"record":{"id":"f7b3f91150266b28","repo":"JeffreySu/WeiXinMPSDK","slug":"senparc-weixin-wxopen-register-registerwxopenaccount","errorCode":null,"errorMessage":"请统一使用请统一使用Senparc.Weixin.WxOpen.Register.RegisterWxOpenAccount()方法进行注册！","messagePattern":"请统一使用请统一使用Senparc\\.Weixin\\.WxOpen\\.Register\\.RegisterWxOpenAccount\\(\\)方法进行注册！","errorType":"exception","errorClass":"WeixinException","httpStatus":null,"severity":"error","filePath":"src/Senparc.Weixin.WxOpen/src/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen/Register.cs","lineNumber":65,"sourceCode":"namespace Senparc.Weixin.WxOpen\n{\n    /// <summary>\n    /// 注册小程序\n    /// </summary>\n    public static class Register\n    {\n        /// <summary>\n        /// 注册小程序信息\n        /// </summary>\n        /// <param name=\"registerService\">RegisterService</param>\n        /// <param name=\"appId\">微信公众号后台的【开发】>【基本配置】中的“AppID(应用ID)”</param>\n        /// <param name=\"appSecret\">微信公众号后台的【开发】>【基本配置】中的“AppSecret(应用密钥)”</param>\n        /// <param name=\"name\">标记AccessToken名称（如微信公众号名称），帮助管理员识别</param>\n        /// <returns></returns>\n        [Obsolete(\"请统一使用Senparc.Weixin.WxOpen.Register.RegisterWxOpenAccount()方法进行注册！\")]\n        public static IRegisterService RegisterWxOpenAccount(this IRegisterService registerService, string appId, string appSercet, string name = null)\n        {\n            throw new WeixinException(\"请统一使用请统一使用Senparc.Weixin.WxOpen.Register.RegisterWxOpenAccount()方法进行注册！\");\n        }\n\n        /// <summary>\n        /// 根据 SenparcWeixinSetting 自动注册小程序信息\n        /// </summary>\n        /// <param name=\"registerService\">RegisterService</param>\n        /// <param name=\"weixinSettingForWxOpen\">SenparcWeixinSetting</param>\n        /// <param name=\"name\">统一标识，如果为null，则使用 SenparcWeixinSetting.ItemKey </param>\n        /// <returns></returns>\n        public static IRegisterService RegisterWxOpenAccount(this IRegisterService registerService, ISenparcWeixinSettingForWxOpen weixinSettingForWxOpen, string name = null)\n        {\n            //配置全局参数\n            if (!string.IsNullOrWhiteSpace(name))\n            {\n                Config.SenparcWeixinSetting[name] = new SenparcWeixinSettingItem(weixinSettingForWxOpen);\n            }\n            AccessTokenContainer.Register(weixinSettingForWxOpen.WxOpenAppId, weixinSettingForWxOpen.WxOpenAppSecret, name ?? weixinSettingForWxOpen.ItemKey);\n            return registerService;","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/JeffreySu/WeiXinMPSDK/blob/be573f6f94bdbf718dd5f6cdecb137fbc7ff651e/src/Senparc.Weixin.WxOpen/src/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen/Register.cs#L47-L83","documentation":"RegisterWxOpenAccount(this IRegisterService, ...) extension method is marked [Obsolete] and unconditionally throws WeixinException telling developers to use the unified Senparc.Weixin.WxOpen.Register.RegisterWxOpenAccount() static registration method instead. Only the parameterless/static form is supported.","triggerScenarios":"Calling the deprecated extension form registerService.RegisterWxOpenAccount(appId, appSecret, name) during app startup configuration of a WxOpen (mini-program) account.","commonSituations":"Copy-paste from old samples or blog posts; migration from older Senparc.Weixin versions where the extension method was valid.","solutions":["Replace the call with the static Senparc.Weixin.WxOpen.Register.RegisterWxOpenAccount(appId, appSecret, name)","Use RegisterWxOpenAccount(...) overload accepting SenparcWeixinSettingItem to register from configuration","Update startup code (usually in startup.cs / Global.asax) to the new API"],"exampleFix":"// before\nservices.AddSenparcWeixinServices(...);\nregisterService.RegisterWxOpenAccount(appId, appSecret, name); // throws\n// after\nSenparc.Weixin.WxOpen.Register.RegisterWxOpenAccount(appId, appSecret, name);\n// or from settings:\nSenparc.Weixin.WxOpen.Register.RegisterWxOpenAccount(senparcWeixinSettingItem);","handlingStrategy":"validation","validationCode":"// Compile-time: calling this [Obsolete] method triggers a compiler warning — fix before release.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the static Senparc.Weixin.WxOpen.Register.RegisterWxOpenAccount() form","Register accounts from SenparcWeixinSetting configuration items","Update samples copied from older documentation","Suppress nothing — fix the source, don't hide the obsolete warning"],"tags":["weixin","obsolete-api","registration"],"backgroundTag":"deprecated-api-usage","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"}