Here is my sample:
using System;
using Windows.Networking.Vpn;
static void main()
{VpnManagementAgent mgr = new VpnManagementAgent();
VpnNativeProfile profile = new VpnNativeProfile() { AlwaysOn = false,
NativeProtocolType = VpnNativeProtocolType.L2tp,
ProfileName = "MyConnection",
RememberCredentials = true, RequireVpnClientAppUI = true,
RoutingPolicyType = VpnRoutingPolicyType.SplitRouting,
TunnelAuthenticationMethod = VpnAuthenticationMethod.PresharedKey,
UserAuthenticationMethod = VpnAuthenticationMethod.Mschapv2, };
profile.Servers.Add("vpn.example.com");
VpnManagementErrorStatus profileStatus = await mgr.AddProfileFromObjectAsync(profile);
Console.WriteLine($"{profileStatus}\n"); }
Here is how I'm trying to compile (from Developer Command Prompt for VS 2019):
csc program.cs /r:Windows.Networking.Vpn.dll
Here is a screenshot of my installed tool-kits:
Here is my output:
Microsoft (R) Visual C# Compiler version 3.100.119.28106 (58a4b1e7)
Copyright (C) Microsoft Corporation. All rights reserved.
error CS0006: Metadata file 'Windows.Networking.Vpn.dll' could not be found
Here is the link from msdn:
Assemblies:Windows.Networking.Vpn.dll, Windows.dll