Skip to content

Windows and .NET integration

Windows / .NET · supported

Supported baseline: Windows x64 and .NET 8. WPF consent UI requires the WebView2 runtime.

Use the source URL and credentials supplied during onboarding:

Terminal window
dotnet nuget add source "$P2PSDK_NUGET_SOURCE" \
--name P2PSDK \
--username "$P2PSDK_NUGET_USER" \
--password "$P2PSDK_NUGET_TOKEN" \
--store-password-in-clear-text
dotnet add package P2PSdk.P2P --version 1.0.0 --source P2PSDK
dotnet add package P2PSdk.P2P.Wpf --version 1.0.0 --source P2PSDK

Prefer your CI secret store and platform credential provider over a clear-text NuGet configuration. For a local onboarding directory, pass its path through --source.

The core package carries p2p_sdk.dll under runtimes/win-x64/native/. Preserve this runtime asset layout.

using P2PSdk.P2P.Wpf;
P2PSdk? sdk = null;
var options = new P2PSdkConsentOptions
{
ApiKey = configuration.ApiKey,
ConsentUrl = configuration.ConsentUrl,
ConsentVersion = configuration.ConsentVersion,
ConsentPublicKeyPem = configuration.ConsentPublicKeyPem,
ParentWindow = mainWindow,
Debug = false,
OnConnect = () => Console.WriteLine("P2PSDK connected"),
OnDisconnect = reason =>
Console.WriteLine($"P2PSDK disconnected: {reason}"),
};
P2PSdkConsentResult result = await P2PSdkConsent.CreateAsync(options);
if (result.IsAccepted && result.Sdk is { } acceptedSdk)
{
sdk = acceptedSdk;
sdk.Connect();
}
else
{
Console.WriteLine($"Consent result: {result.Status}: {result.Message}");
}

The helper owns consent verification and local decision state. Handle declined, revoked, cancelled, and error results without creating a core instance manually.

Non-WPF applications may create the core wrapper only with an approved receipt source:

using P2PSdk.P2P;
using var sdk = new P2PSdk(new P2PSdkOptions
{
ApiKey = configuration.ApiKey,
ConsentReceipt = approvedConsentReceipt,
Debug = false,
IdentityPath = configuration.IdentityPath,
OnConnect = () => Console.WriteLine("connected"),
OnDisconnect = reason => Console.WriteLine($"disconnected: {reason}"),
});
sdk.Connect();
Console.WriteLine($"Online: {sdk.IsOnline}");

Passing Consent = true is deprecated and insufficient. Use the WPF helper whenever the host has WPF UI.

Without DeviceIdentitySeed, the wrapper persists a generated seed under user application data or the configured IdentityPath. The managed resolver loads p2p_sdk.dll from the NuGet runtime asset or application output directory.

Do not copy the DLL from a different release. Diagnose resolution failures using the packaged output, process architecture, and Windows loader logs before adding global DLL search paths.

A normal Windows desktop process continues while its windows are minimized or hidden, so the SDK supervisor can continue while the process lives. The wrapper does not install a Windows service, add autostart, recover after force close, or prevent system sleep.

P2PSdkConsentRevokeResult revoked =
await P2PSdkConsent.RevokeAsync(options, sdk);
if (revoked.IsRevoked)
{
sdk = null; // The helper disposed the active instance.
}

Set P2P_SDK_CONSENT_REVOKE_URL before revoke. Keep the instance on failure. Call Disconnect() to pause and Dispose() exactly once at terminal shutdown.

  • Verify WebView2 availability and every consent result.
  • Confirm p2p_sdk.dll is present in the final win-x64 runtime/output layout.
  • Test minimize, hide/show, session lock, sleep/resume, network loss, process exit, and revoke.
  • Ensure event handlers do not block the native callback path and exceptions are contained.