Created
May 24, 2023 17:09
-
-
Save DHowett/7e5c1187da7c33d85edb3da35d35c1c3 to your computer and use it in GitHub Desktop.
IWebAccount2 - C#/WinRT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>net7.0-windows10.0.22000.0</TargetFramework> | |
<ImplicitUsings>enable</ImplicitUsings> | |
<Nullable>enable</Nullable> | |
<!-- **** IMPORTANT 1 - Add the Windows.Security namespace to the list of generated projections --> | |
<CsWinRtIncludes>Windows.Security</CsWinRtIncludes> | |
</PropertyGroup> | |
<ItemGroup> | |
<!-- **** IMPORTANT 2 - This generates the projections --> | |
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.2" /> | |
</ItemGroup> | |
</Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Windows.Security.Credentials; | |
using WinRT; | |
namespace CredentialCsWinRtTest { | |
internal class Program { | |
static void Main(string[] args) { | |
Windows.Security.Credentials.WebAccount foo = null /* or somehow get it */; | |
Windows.Security.Credentials.IWebAccount2 webAccount2 = foo.As<IWebAccount2>(); | |
// if webaccount2 is not null . . . | |
webAccount2.SignOutAsync("clientId"); // do something with the async task actually | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is probably important to set the TFM to include
-windows10.0.xxxxx
, where that number is one of the Windows SDKs you have installed.