命名空间“Windows”中不存在类型或命名空间名称“安全”(您是否缺少程序集引用?)

时间:2018-01-16 18:36:17

标签: c# .net security namespaces xamarin-studio

我正在尝试使用'Windows.Security.Credentials'来运行脚本,但是IDE给了我标题中提到的错误,特别是在第6行。Someone已经尝试帮助我,但他们的回答是我太懂技术了。我询问了有关如何执行答案的详细信息,但他们从未做出回应。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Security.Credentials;

namespace PasswordVaultTest
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create a handle to the Widnows Password vault
            Windows.Security.Credentials.PasswordVault vault = new PasswordVault();
            // Retrieve all the credentials from the vault
            IReadOnlyList<PasswordCredential> credentials = vault.RetrieveAll();
            // The list returned is an IReadOnlyList, so there is no enumerator.
            // No problem, we'll just see how many credentials there are and do it the
            // old fashioned way
            for (int i = 0; i < credentials.Count; i++)
            {
                // Obtain the credential
                PasswordCredential cred = credentials.ElementAt(i);
                // "Fill in the password" (I wish I knew more about what this was doing)
                cred.RetrievePassword();
                // Print the result
                Console.WriteLine(cred.Resource + ':' + cred.UserName + ':' + cred.Password);
            }
            Console.ReadKey();
        }
    }
}

0 个答案:

没有答案