首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RandomNumberGenerator in ASP.NET5

RandomNumberGenerator in ASP.NET5
EN

Stack Overflow用户
提问于 2015-12-17 22:13:50
回答 1查看 896关注 0票数 2

我使用ASP.NET 5模板创建了一个新的Web项目。我希望使用System.Security.Cryptography.RandomNumberGenerator生成随机数,但在.NET平台5.4中没有它(见屏幕快照)。

编译它还会产生以下错误:

代码语言:javascript
复制
Error   CS0234  The type or namespace name 'Cryptography' does not exist in the namespace 'System.Security' (are you missing an assembly reference?)

Error   CS0246  The type or namespace name 'RandomNumberGenerator' could not be found (are you missing a using directive or an assembly reference?)

Error   CS0103  The name 'RandomNumberGenerator' does not exist in the current context

是否有一种使用此方法的方法,或者是否有一种我可以使用的具有密码安全性的随机生成器?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-12-17 23:28:09

多亏了斯科特·张伯伦( Scott )的评论,我才让它发挥作用,增加了System.Security.Cryptography.Algorithms NuGet软件包。

我还必须修改project.json,因此它只是dotnet5.4的依赖项,而不是全局依赖项,否则编译器会抱怨RandomNumberGenerator同时存在于System.Security.Cryptography.Algorithms和mscorlib中。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34345271

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档