JeffreySu/WeiXinMPSDK · error · WeixinOpenException
此appId尚未注册,ComponentContainer.Register完成注册(全局执行一次即可)!
Error message
此appId尚未注册,ComponentContainer.Register完成注册(全局执行一次即可)!
What it means
TryGetComponentVerifyTicket looks up the component_verify_ticket for a registered open-platform component. If CheckRegistered fails for the componentAppId it throws WeixinOpenException with the UN_REGISTER_ALERT message, meaning ComponentContainer.Register was never called (or app cache was flushed without re-registration).
Solutions
- Call ComponentContainer.Register(componentAppId, componentSecret, GetComponentVerifyTicketFunc) once at application startup.
- Ensure registration runs in every process/app-domain (e.g. also in background workers), not just in the web root.
- Confirm the componentAppId matches the registered one.
- Check the cache is persistent/consistent so registration state survives restarts.
Example fix
// before var ticket = ComponentContainer.TryGetComponentVerifyTicket(componentAppId); // after ComponentContainer.Register(componentAppId, componentSecret, GetComponentVerifyTicketFunc); var ticket = ComponentContainer.TryGetComponentVerifyTicket(componentAppId);
Defensive patterns
Strategy: validation
Validate before calling
if (!ComponentContainer.CheckRegistered(componentAppId))
ComponentContainer.Register(componentAppId, componentSecret, GetComponentVerifyTicketFunc); Try / catch
try { ticket = ComponentContainer.TryGetComponentVerifyTicket(componentAppId); }
catch (WeixinOpenException ex) { logger.Error(ex, "Component not registered: {0}", componentAppId); throw; } Prevention
- Register once globally at startup in every process
- Use shared cache across instances
- Validate appId configuration values
When it happens
Trigger: Calling ComponentContainer.TryGetComponentVerifyTicket, GetComponentAccessTokenResult, or componentVerifyTicket with an appId not registered via ComponentContainer.Register in the current process/cache.
Common situations: Forgot the one-time global registration at startup; app domain recycled and registration happens only in Application_Start of a worker that wasn't restarted; cache backend cleared; wrong componentAppId passed.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- 注册AuthorizerContainer之前,必须先注册对应的ComponentContainer!Component…
- GetComponentVerifyTicketFunc必须在注册时提供!
- 注册委托容量必须大于 0。
- 当前已有 个注册委托,不能把容量降低到 。
- 注册委托数量已达到上限 ,请先注销不再使用的账号或提高…
AI-assisted analysis of JeffreySu/WeiXinMPSDK@be573f6f94 (2026-09-12).
Data as JSON: /api/errors/809a102d2e6ba47d.
Report an issue: GitHub.
Appendix: source
Thrown at src/Senparc.Weixin.Open/Senparc.Weixin.Open/Containers/ComponentContainer.cs:261
if (!CheckRegistered(componentAppId) || getNewToken)
{
Register(componentAppId, componentAppSecret, null, null, null, name);
}
}
#region component_verify_ticket
/// <summary>
/// 获取ComponentVerifyTicket
/// </summary>
/// <param name="componentAppId"></param>
/// <param name="getNewToken"></param>
/// <returns>如果不存在,则返回null</returns>
public static string TryGetComponentVerifyTicket(string componentAppId, bool getNewToken = false)
{
if (!CheckRegistered(componentAppId))
{
throw new WeixinOpenException(UN_REGISTER_ALERT);
}
var bag = TryGetItem(componentAppId);
using (Cache.BeginCacheLock(LockResourceName + ".TryGetComponentVerifyTicket", componentAppId))
{
bag = TryGetItem(componentAppId);//获锁后重新读取并二次检查过期状态
var componentVerifyTicket = bag.ComponentVerifyTicket;
if (getNewToken || componentVerifyTicket == default(string) || bag.ComponentVerifyTicketExpireTime < SystemTime.Now)
{
if (GetComponentVerifyTicketFunc == null)
{
throw new WeixinOpenException("GetComponentVerifyTicketFunc必须在注册时提供!", bag);
}
componentVerifyTicket = GetComponentVerifyTicketFunc(componentAppId).ConfigureAwait(false).GetAwaiter().GetResult(); //获取最新的componentVerifyTicket
bag.ComponentVerifyTicket = componentVerifyTicket;
bag.ComponentVerifyTicketExpireTime = ApiUtility.GetExpireTime(COMPONENT_VERIFY_TICKET_UPDATE_MINUTES * 60);
Update(bag, null);//更新到缓存
}View on GitHub (pinned to be573f6f94)