直接引用windows命名空间

< ![CDATA[

再逛博客的时候,看见一段这样代码.获取系统密码的

   static void DumpCredentials(Windows.Security.Credentials.PasswordCredential cred)
        {
            Console.WriteLine("Resource: {0}", cred.Resource);
            Console.WriteLine("UserName: {0}", cred.UserName);
            Console.WriteLine("Password: {0}", cred.Password);



        }
        static void Main(string[] args)
        {
            Windows.Security.Credentials.PasswordVault vault = new Windows.Security.Credentials.PasswordVault();
            Console.WriteLine("{0}", vault.GetType());
            foreach (var cred in vault.RetrieveAll())
            {
                cred.RetrievePassword();
                DumpCredentials(cred);
            }
            Console.ReadKey();
        }

然后我复制进去,试试,

发现 Windows.Security.Credentials.PasswordCredential      无法引用.

要引用Windows 命名空间,我右键项目,再引用里面,没找到..

后来搜了下.

再 .csproj 项目文件里面加了句话

  <PropertyGroup>
    <TargetPlatformVersion>8.0</TargetPlatformVersion>
  </PropertyGroup>

然后再 引用里面
 浏览 C:Program Files (x86)Windows Kits8.0ReferencesCommonConfigurationNeutral 下的文件 ,选择引用

 

会发现有些不一样吧..上面多出了了个windows tag.

 

引用:

http://msdn.microsoft.com/library/hh708954%28v=vs.110%29.aspx

 

 

 

 

 

]]>

你可能感兴趣的:(windows)