Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
446 views
in Technique[技术] by (71.8m points)

c# - TypeInitializationException / SSL library issue with dotnet core and Ubuntu

I have a dotnet core app (netcoreapp3.1) that crashes with the following error on launch:

$ dotnet run
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 shared library 'libSystem.Security.Cryptography.Native.OpenSsl' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibSystem.Security.Cryptography.Native.OpenSsl: cannot open shared object file: No such file or directory
   at Interop.CryptoInitializer.EnsureOpenSslInitialized()
   at Interop.CryptoInitializer..cctor()
   --- End of inner exception stack trace ---
   at Interop.CryptoInitializer.Initialize()
   at Interop.Crypto..cctor()
   --- End of inner exception stack trace ---
   at Interop.Crypto.EvpPkeyDestroy(IntPtr pkey)
   at System.Security.Cryptography.SafeEvpPKeyHandle.ReleaseHandle()
   at System.Runtime.InteropServices.SafeHandle.InternalRelease(Boolean disposeOrFinalizeOperation)
   at System.Runtime.InteropServices.SafeHandle.Dispose(Boolean disposing)
   at System.Runtime.InteropServices.SafeHandle.Finalize()

I have searched for this error, but most of the discussion is from 2016.

I am using Ubuntu 20.04.

System info:

$ openssl version 
OpenSSL 1.0.2n  7 Dec 2017

$ dotnet --version
5.0.101

$ lsb_release -a 
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:    20.04
Codename:   foca

How can I run this application?


Update, I ran sudo apt-get install lsb-core.

It still does not work, but lsb_release -a is now different:

$ lsb_release -a 
LSB Version:    core-11.1.0ubuntu2-noarch:security-11.1.0ubuntu2-noarch
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:    20.04
Codename:   focal

Related, but macOS dotnet core in macOS: "The type initializer for 'Crypto' threw an exception"


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...