runtime icon indicating copy to clipboard operation
runtime copied to clipboard

HttpClient ctor failed on Mac due to Unable to load DLL 'System.Security.Cryptography.Native'

Open hongdai opened this issue 10 years ago • 10 comments

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()

hongdai avatar Mar 02 '16 19:03 hongdai

Could it be related to https://github.com/dotnet/corefx/issues/2546?

hongdai avatar Mar 02 '16 19:03 hongdai

Have you done the steps listed here: https://github.com/dotnet/coreclr/blob/master/Documentation/building/osx-instructions.md#openssl?

ellismg avatar Mar 05 '16 03:03 ellismg

@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?

ericeil avatar Mar 07 '16 23:03 ericeil

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.

hongdai avatar Mar 07 '16 23:03 hongdai

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.

ellismg avatar Mar 08 '16 00:03 ellismg

Closing this issue; please reopen if updating OpenSSL/building System.Native.dylib doesn't fix the problem.

ericeil avatar Mar 08 '16 00:03 ericeil

Do you have the OpenSSL/building System.Native.dylib package somewhere I can use instead of building them myself?

hongdai avatar Mar 08 '16 20:03 hongdai

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 avatar Mar 08 '16 20:03 hongdai

@hongdai

The only step required to consume the bits is the brew openssl step:

brew install openssl
brew link --force openssl

ellismg avatar Mar 08 '16 20:03 ellismg

@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.

mconnew avatar Mar 14 '16 21:03 mconnew