Skip to content

VpnManagementAgent::GetProfilesAsync does not work in a Win32 app, but works in a UWP app #3419

@overthro

Description

@overthro

Describe the bug

VpnManagementAgent::GetProfilesAsync is supposed to return a list of your VPN profiles. But it gives me an empty vector in C++/WinRT. Running as an administrator does not help.

Steps to reproduce the bug

#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.Networking.Vpn.h>

using namespace winrt::Windows::Networking::Vpn;

int main() {
    winrt::init_apartment();

    VpnManagementAgent vpn{};
    auto profiles = vpn.GetProfilesAsync().get();
    printf("Found %d profiles\n", profiles.Size());
}

Expected behavior

The very same function however returns all my vpn profiles in this UWP app.

Edit. I thought I'd add that strangely VpnManagementAgent::AddProfileFromObjectAsync works, if I run as administrator. VpnManagementAgent::GetProfilesAsync seems to be have faulty logic. I suspect that its logic presumes that a caller is always a UWP app and therefore not only has a package manifest but also has the required capabilities declared, which will not be true, if it is a Win32 app.

Screenshots

No response

NuGet package version

None

Packaging type

No response

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

No response

Additional context

Visual Studio 2022 17.5.0 Preview 1.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-ExternalTopics external to Windows App SDK

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions