Click here to Skip to main content
13,558,063 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am getting exception while passing a long string to save to the windows vault folder using c# and Credential Manager API. Else it is getting saved successfully to the vault.

Exception coming is
Specified argument was out of the range of valid values.

Parameter name: The password has exceeded 512 bytes.


What I have tried:

public void SavePassword(string password)
               using (var cred = new Credential())
                   cred.Password = password;
                   cred.Target = PasswordName;
                   cred.Type = CredentialType.Generic;
                   cred.PersistanceType = PersistanceType.LocalComputer;
           catch(Exception ex)


Posted 18-May-18 1:31am
Updated 18-May-18 1:42am
gkp1992 18-May-18 7:39am
Just me or the password string goes on and on in a single line overflowing the CP page?Chrome by the way.
RichardDeeming 18-May-18 9:40am
It's not just you. The browser can't find an obvious place to break the line, so without word-wrap: break-word; on the containing <div>, it won't wrap onto a new line.
gkp1992 5 days ago
Why do you need to have such a long password anyway? Can a user ever remember that?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Parameter name: The password has exceeded 512 bytes.

Your password is 600 bytes long and the maximum allowed is 512.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03-2016 | 2.8.180515.1 | Last Updated 18 May 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100