RegisterSrv.ClientSDK
1.3.1
dotnet add package RegisterSrv.ClientSDK --version 1.3.1
NuGet\Install-Package RegisterSrv.ClientSDK -Version 1.3.1
<PackageReference Include="RegisterSrv.ClientSDK" Version="1.3.1" />
<PackageVersion Include="RegisterSrv.ClientSDK" Version="1.3.1" />
<PackageReference Include="RegisterSrv.ClientSDK" />
paket add RegisterSrv.ClientSDK --version 1.3.1
#r "nuget: RegisterSrv.ClientSDK, 1.3.1"
#:package RegisterSrv.ClientSDK@1.3.1
#addin nuget:?package=RegisterSrv.ClientSDK&version=1.3.1
#tool nuget:?package=RegisterSrv.ClientSDK&version=1.3.1
RegisterSrv.ClientSDK
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 | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0-windows7.0 is compatible. net10.0-windows was computed. |
-
net9.0-windows7.0
- Microsoft.Extensions.Configuration (>= 9.0.0)
- Microsoft.Extensions.Configuration.Json (>= 9.0.0)
- Newtonsoft.Json (>= 13.0.3)
- RegisterSrv.Core (>= 1.0.0)
- System.Configuration.ConfigurationManager (>= 9.0.0)
- System.Management (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
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 页面展示富文本