HttpClient ctor failed on Mac due to Unable to load DLL 'System.Security.Cryptography.Native'
Call stack: Unhandled exception of type 'System.TypeInitializationException': System.TypeInitializationException : The type initializer for 'System.Net.Http.CurlHandler' threw an exception.\n---- System.TypeInitializationException : The type initializer for 'Http' threw an exception.\n-------- System.TypeInitializationException : The type initializer for 'HttpInitializer' threw an exception.\n------------ System.TypeInitializationException : The type initializer for 'CryptoInitializer' threw an exception.\n---------------- System.DllNotFoundException : Unable to load DLL 'System.Security.Cryptography.Native': The specified module could not be found.\n (Exception from HRESULT: 0x8007007E) at System.Net.Http.CurlHandler..ctor() at System.Net.Http.HttpClient..ctor()
Could it be related to https://github.com/dotnet/corefx/issues/2546?
Have you done the steps listed here: https://github.com/dotnet/coreclr/blob/master/Documentation/building/osx-instructions.md#openssl?
@hongdai, is this solved by @ellismg's suggestion?
Have you done the steps listed here: https://github.com/dotnet/coreclr/blob/master/Documentation/building/osx-instructions.md#openssl?
So I cannot build the particular library on Windows for OSX yet? What i'm trying to achieve is build everything on Windows, then deploy to an OSX machine to run.
You can not build the native shims on Windows, they must be built on the target machine. Managed code can be built on Windows, however.
The native shim will need the above to both compile and run.
Closing this issue; please reopen if updating OpenSSL/building System.Native.dylib doesn't fix the problem.
Do you have the OpenSSL/building System.Native.dylib package somewhere I can use instead of building them myself?
The documentation on https://github.com/dotnet/coreclr/blob/master/Documentation/building/osx-instructions.md#openssl? is for someone who will build the corefx. I need a documentation that just consume your bits, no building involved.
@hongdai
The only step required to consume the bits is the brew openssl step:
brew install openssl
brew link --force openssl
@ellismg, the exception message says
Unable to load DLL 'System.Security.Cryptography.Native': The specified module could not be found
Is the problem really that System.Security.Cryptography.Native couldn't find the openssl library? If so, the error message is very obscure and we should do something to improve it so that the true nature of the failure is apparent.