macOS 中的 dotnet 核心:“'Crypto' 的类型初始值设定项引发异常" [英] dotnet core in macOS: "The type initializer for 'Crypto' threw an exception"

查看:23
本文介绍了macOS 中的 dotnet 核心:“'Crypto' 的类型初始值设定项引发异常"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照 .NET Core 网站 上的说明进行操作,但出现此错误.显然,缺少一些先决条件.知道如何安装这些吗?

I followed the instructions on the .NET Core website, but got this error. Apparently there are some pre-reqs which are missing. Any idea how to install those?

mymac:~ naveen.vijay$ dotnet new

Unhandled Exception: System.TypeInitializationException: The type initializer for 'Crypto' threw an exception. ---> System.TypeInitializationException: The type initializer for 'CryptoInitializer' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'System.Security.Cryptography.Native': The specified module could not be found.
 (Exception from HRESULT: 0x8007007E)
   at Interop.CryptoInitializer.EnsureOpenSslInitialized()
   at Interop.CryptoInitializer..cctor()
   --- End of inner exception stack trace ---
   at Interop.Crypto..cctor()
   --- End of inner exception stack trace ---
   at Interop.Crypto.GetRandomBytes(Byte* buf, Int32 num)
   at System.IO.Path.GetCryptoRandomBytes(Byte* bytes, Int32 byteCount)
   at System.IO.Path.GetRandomFileName()
   at Microsoft.DotNet.InternalAbstractions.TemporaryDirectory..ctor()
   at Microsoft.Extensions.EnvironmentAbstractions.DirectoryWrapper.CreateTemporaryDirectory()
   at Microsoft.DotNet.Configurer.NuGetPackagesArchiver..ctor()
   at Microsoft.DotNet.Cli.Program.ConfigureDotNetForFirstTimeUse(INuGetCacheSentinel nugetCacheSentinel)
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
   at Microsoft.DotNet.Cli.Program.Main(String[] args)
Abort trap: 6

推荐答案

macOS 的安装说明已过时.请参阅 Github 上的此讨论:SSL 无法使用 Brew 链接.

The install instructions for macOS are out of date. See this discussion on Github: SSL Fails to Link Using Brew.

我在 macOS El Capitan 上安装 .NET Core 时遇到了这个问题.来自这个答案的解决方案正在运行以下内容:

I ran into this myself when installing .NET Core on macOS El Capitan. The solution, from this answer, is running the following:

sudo install_name_tool -add_rpath /usr/local/opt/openssl/lib /usr/local/share/dotnet/shared/Microsoft.NETCore.App/1.0.0/System.Security.Cryptography.Native.dylib

在我的终端中运行该命令后,dotnet new 运行良好.

After running that command in my terminal, dotnet new worked fine.

这篇关于macOS 中的 dotnet 核心:“'Crypto' 的类型初始值设定项引发异常"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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