RegisterSrv.ClientSDK 1.3.2

dotnet add package RegisterSrv.ClientSDK --version 1.3.2
                    
NuGet\Install-Package RegisterSrv.ClientSDK -Version 1.3.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RegisterSrv.ClientSDK" Version="1.3.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RegisterSrv.ClientSDK" Version="1.3.2" />
                    
Directory.Packages.props
<PackageReference Include="RegisterSrv.ClientSDK" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add RegisterSrv.ClientSDK --version 1.3.2
                    
#r "nuget: RegisterSrv.ClientSDK, 1.3.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package RegisterSrv.ClientSDK@1.3.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=RegisterSrv.ClientSDK&version=1.3.2
                    
Install as a Cake Addin
#tool nuget:?package=RegisterSrv.ClientSDK&version=1.3.2
                    
Install as a Cake Tool

RegisterSrv.ClientSDK

NuGet License: MIT

RegisterSrv 体系下的客户端 SDK:注册码验证、机器码生成、试用申请、服务器联系信息、无码引导、自动升级。

一行集成

LicenseManager.Initialize("YourAppId", "http://localhost:5232");
if (!await LicenseManager.EnsureLicenseValidAsync("我的应用", "1.0.0", owner: this))
{
    Application.Current.Shutdown();
}

能力清单

能力 类型 / 入口 说明
注册码验证 LicenseClient.ValidateLicenseAsync /api/license/validate
机器码生成 MachineCodeHelper.GenerateMachineCode 32 位大写十六进制(Core 内统一)
试用申请 LicenseClient.RequestTrialAsync /api/trial/apply
服务器联系信息 LicenseClient.GetContactInfoAsync /api/server/contact-info
二维码下载 LicenseClient.GetWechatQrCodeAsync /api/server/wechat-qrcode
无码引导 LicenseManager.EnsureLicenseValidAsync / FeedbackClient 自动留资 + 浏览器 + 轮询
WebSocket 实时发码 FeedbackClient.CreateChannel(machine) /feedback/ws/{machine}(可选)
离线缓存 LicenseManager.ValidateCurrentLicenseAsync 自动启用 24h TTL,存于 %LOCALAPPDATA%\Registersrv\license.cache
类型翻译 LicenseTypeFormatter.Format(licenseType) "Weekly"→"周卡" 等
内置 WPF 注册窗口 new LicenseWindow(...) 含试用申请 UI

安装

dotnet add package RegisterSrv.ClientSDK

配套升级模块(自动更新):

dotnet add package RegisterSrv.AutoUpdate

最小 App.xaml.cs

public partial class App : Application
{
    private UpdateManager? _update;

    protected override async void OnStartup(StartupEventArgs e)
    {
        base.OnStartup(e);

        var appId      = ConfigurationManager.AppSettings["RegisterSrv.AppId"] ?? "YourAppId";
        var serverUrl  = ConfigurationManager.AppSettings["RegisterSrv.ServerUrl"] ?? "http://localhost:5232";
        var appVersion = typeof(App).Assembly.GetName().Version!.ToString(3);

        LicenseManager.Initialize(appId, serverUrl);

        _update = new UpdateManager(new UpdateConfig
        {
            ServerUrl          = serverUrl,
            AppId              = appId,
            CurrentVersion     = appVersion,
            AutoCheckOnStartup = true,
            SilentUpdate       = false
        });

        await _update.AutoCheckAndUpdateAsync(this, silent: true);

        if (!await LicenseManager.EnsureLicenseValidAsync("我的应用", appVersion, owner: this))
        {
            Shutdown();
            return;
        }

        var main = new MainWindow();
        MainWindow = main;
        main.Show();
    }

    protected override void OnExit(ExitEventArgs e)
    {
        LicenseManager.Cleanup();
        _update?.Dispose();
        base.OnExit(e);
    }
}

完整文档

参见 客户端集成指南。

Product Compatible and additional computed target framework versions.
.NET net9.0-windows7.0 is compatible.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.2 109 10/27/2026
1.3.1 131 9/9/2026
1.3.0 133 9/9/2026
1.0.1 256 10/21/2025
1.0.0 168 9/27/2025

v1.3.2 (2026-10-27): [hotfix] 修复 CDN 防盗链导致升级包下载 403
 • UpdateClient 下载升级包时自动补 Referer 请求头(新增内部 AntiHotlinkHeaders)
   背景:升级包放在腾讯云 COS 桶前面挂了 CDN,CDN 控制台开了「Referer 防盗链」,
   只放行主机名恰好等于站点主域(如 ujuji.cn)的请求。HttpClient 默认不发 Referer,
   因此下载会被 CDN 判 403,表现为「下载失败: HTTP 403」。
 • Referer 的主机从「客户端自己配置的更新服务器地址」推导主域(最后两段),
   私有化部署时即为客户自己的域名,自动适配其 CDN 白名单;取不到时退回下载目标地址。
 • 显式启用 HttpClientHandler.AllowAutoRedirect(跟随服务端 302 → CDN 直链),
   实测 .NET 跨主机重定向会保留 Referer,直连 CDN 与 302 跳转两条路径均已验证通过。
 • 依赖升级:RegisterSrv.Core 1.0.1(COS + CDN 存储抽象)。
 • 无对外 API 变更(AntiHotlinkHeaders 为 internal),建议所有 1.3.1 用户升级。

v1.3.1 (2026-09-10): [hotfix]
 • LicenseWindow:移除 GetContactInfoAsync / GetWechatQrCodeAsync 上的 ConfigureAwait(false),避免在 WPF
   UI 线程中 DebugLog 或后续访问 Image.Source / TextBlock.Text 时跨线程,修复 1.3.0 首发后客户端偶发
   "调用线程无法访问此对象..." 或后续 UI 状态异常。
 • 无对外 API 变更、无二进制行为变更(除上述线程上下文),建议所有 1.3.0 用户升级。

v1.3.0 (2026-09-09):
 • 重构:解决 LicenseClient 同名双定义(统一移至 RegisterSrv.ClientSDK.Services)
 • 统一机器码:LicenseClient.GetMachineCode 直接调用 Core.MachineCodeHelper,结果跨 SDK 一致
 • 新增离线缓存 LicenseCache(24h TTL),LicenseManager.ValidateCurrentLicenseAsync 自动启用,新增 UsedOfflineCache 字段
 • 新增无码引导 FeedbackClient(SubmitAsync / PollAsync / CreateChannel)
 • 新增 WebSocket 实时发码订阅 FeedbackChannel
 • 新增公开静态类 LicenseTypeFormatter.Format(string?)
 • LicenseManager.EnsureLicenseValidAsync 内置"引导留资"完整流程,调用方一行代码搞定
 • LicenseManager.Initialize 配置优先级:入参 > ClientConfig(json) > App.config > 默认值
 • 新增内部 Dialogs.WaitWindow / PromptBox(SDK 内部使用,UI 可定制)
 • 新增 README.md,NuGet 页面展示富文本