PasswordVault.Add may fail on Windows 10


I am slightly embarrassed by the length of time since my last blog post. But never mind, here I am again!

I’ve been working on a customer issue lately where an existing Windows Store app was failing on Windows 10. Initially the app, which ran fine on Windows 8.1 was crashing when installed and run, unaltered, on Windows 10.  The code involved looked something like this:

           var vault = new PasswordVault();
           // Add the new credential
           var passwordCredential = new PasswordCredential("test", "user", "password");



               // *** This should not give an error ***
               return "Successfully added credential!";

           catch (Exception excp)
               return "Failed!" + excp.ToString();

PasswordVault is a handy class that allows you to securely store credentials used by your Windows Store or Windows Phone 8.1 app.

The .NET exception thrown was System.ArgumentException with the text “The parameter is incorrect. Cannot add credential to Vault”.  Of course, without the exception handler the app was crashing. With the exception handler it was not crashing but the credentials were not stored either. Not very useful.

As is often the way when debugging, I started by getting the customer’s solution into a state where I could compile and debug it locally, eliminating dependencies I did not have or need.  At that point I could reproduce the issue.  Next step was to start from a blank solution and build it up, adding similar code to that used in the customer’s solution. Interestingly that did not fail! So there had to be some other factor.

Anyway, to cut a long story short, it turned out this is a corner case that depends on the full app names length.  As a result, this only affects a very small number of apps.  The good news is that we got a bug filed and a fix through the system which has now been released, as of yesterday’s cumulative update:

Cumulative Update for Windows 10: August 27, 2015 (KB3081448)

Hope that helps