Click here to Skip to main content
13,254,366 members (63,381 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I have got a build error in the following code....

string password = "Global12$";
string userName = @"myindia.local\Administrator";
SecureString ss = ConvertToSecureString(password);

This is the error message

The name 'ConvertToSecureString' does not exist in the current context

I don't know how to solve this? Which namespace is missing? Any help on this would be great.

Thanks & Regards
Posted 15-Jun-12 3:51am
Updated 17-Jun-12 20:20pm
ryanb31 15-Jun-12 8:58am
A quick google search indicates using ConvertTo-SecureString. Have you tried that?
Sebastian T Xavier 15-Jun-12 9:22am
If you can show some examples of this , that would be great!!!
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Not sure if this is what you're looking for, but try this link:
ConvertToSecureString Class[^] on MSDN.
It has some examples there.
Edited: This can't be the right answer :)

On second thought look at the comments at the bottom here[^]

Maybe that's where this mysterious method came from ;)

private SecureString ConvertToSecureString(string value)
    SecureString ret = new SecureString();
    foreach (char c in value)
    return ret;
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

ConvertToSecureString is a private method , which you need to write in your own class.

As mentioned[^], you need to write your own version of ConvertToSecureString method.

Rushikesh Joshi
Sebastian T Xavier 18-Jun-12 1:19am
Thanks for your reply. But I think , I am looking for another method. Please have a look at the following URL.


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 |
Web01 | 2.8.171114.1 | Last Updated 18 Jun 2012
Copyright © CodeProject, 1999-2017
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