我已经按照 this article 中的描述引用了文件 System.Security.dll
但是根据我的 IDE,行 using System.Security.Cryptography;
可以安全地删除,因为它没有被使用。
同一 IDE 告诉我 DataProtectionScope
和 ProtectedData
出错。这些应该在that 命名空间中。但是,当我在包裹中点点时,我看不到它们。
文章有错吗?如何访问这两个类?
最佳答案
正如@Coral Doe 在@Dave Lucre 下的评论中提到的那样:
"Had a similar problem and this worked. using System.Security.Cryptography; didn't [show] me [ProtectedData] and ProtectedMemory until I had referenced the System.Security.dll for the specific framework."
这解决了我的问题。具体来说,我执行了以下步骤:
- 在 Visual Studio 中打开项目。
- 在“解决方案资源管理器”中右键单击项目名称,然后选择“属性”。
- 单击左侧的“引用”选项卡。
- 单击“添加”按钮。
- 单击 .NET 选项卡。
- 选择 System.Security 并单击“确定”以添加引用。
希望这对您有所帮助。
关于c# - 在 System.Security.Cryptography 中找不到 `DataProtectionScope` 和 `ProtectedData` 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12526189/