名称"ConvertToSecureString"在当前上下文中不存在 [英] The name 'ConvertToSecureString' does not exist in the current context

查看:80
本文介绍了名称"ConvertToSecureString"在当前上下文中不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码中出现构建错误....

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



我不知道该怎么解决?缺少哪个名称空间?在这方面的任何帮助将是巨大的.

谢谢&问候
Sebastian



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

Thanks & Regards
Sebastian

推荐答案

"; 字符串 userName = @" ; SecureString ss = ConvertToSecureString(password);
"; 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
Sebastian


不确定这是否是您要寻找的东西,但是请尝试以下链接:
ConvertToSecureString类 [ ^ ].
那里有一些示例.
这可能不是正确的答案:)

再三考虑时,请查看底部此处的评论. "http://msdn.microsoft.com/zh-cn/library/system.security.securestring.aspx" target ="_ blank" title =新窗口"> ^ ]

也许这就是这种神秘方法的来源;)

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)
    {
        ret.AppendChar(c);
    }
    ret.MakeReadOnly();
    return ret;
}


ConvertToSecureString是一个私有方法,您需要在自己的类中编写.

如前所述, http://msdn.microsoft.com/en-us/library/system. security.securestring.aspx [ ^ ],则需要编写自己的ConvertToSecureString方法版本.

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

As mentioned http://msdn.microsoft.com/en-us/library/system.security.securestring.aspx[^], you need to write your own version of ConvertToSecureString method.

Thanks
Rushikesh Joshi


这篇关于名称"ConvertToSecureString"在当前上下文中不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆