UWP VPN配置文件没有';无法创建VPN连接

UWP VPN配置文件没有';无法创建VPN连接,uwp,vpn,Uwp,Vpn,我创建了一个VPN配置文件,但没有设置:名称、密码和身份验证方法。我试图以管理员的身份运行该项目,但它也不起作用。有什么问题吗 auto mgr = ref new VpnManagementAgent(); auto profile = ref new VpnNativeProfile(); profile->AlwaysOn = true; profile->N

我创建了一个VPN配置文件,但没有设置:名称、密码和身份验证方法。我试图以管理员的身份运行该项目,但它也不起作用。有什么问题吗

  auto mgr = ref new VpnManagementAgent();

  auto  profile                          =   ref new VpnNativeProfile();
  profile->AlwaysOn                      =   true;
  profile->NativeProtocolType            =   VpnNativeProtocolType::L2tp;
  profile->UserAuthenticationMethod      =   VpnAuthenticationMethod::PresharedKey;
  profile->ProfileName                   =   "TestVpn";
  profile->RememberCredentials           =   true;
  profile->RequireVpnClientAppUI         =   true;
  profile->RoutingPolicyType             =   VpnRoutingPolicyType::ForceAllTrafficOverVpn;
  profile->Servers->Append("101.99.74.214");  

  auto profileStatus    = mgr->UpdateProfileFromObjectAsync(profile);

  auto credentials      = ref new PasswordCredential();
  credentials->UserName = "vpn";
  credentials->Password = "vpn";  

  auto connectStatus  = mgr->ConnectProfileWithPasswordCredentialAsync(profile, credentials);

您好,您是否在
Package.appxmanifest
中声明networkingVpnProvider的功能,这是一种受限功能。有关详细信息,请参阅此。@Richard Zhang-MSFT Hi,我在
Package.appxmanifest
中添加了
。但这没用,uwp限制了它。我的朋友在两年前尝试过这样做,但还是失败了。如果您想以编程方式存储用户名和密码,可以尝试在应用程序容器的appdata中手动编辑pbk文件。这可能涉及一些黑客在用户界面设置用户名和密码后比较pbk的值,