Why doesn't .NET find the OpenSSL.NET dll?

2019-01-18 13:04发布

EDIT (the whole question, it was too unclear)

I want to use OpenSSL.NET

The OpenSSL.NET install instructions page: INSTALL

Make sure you have libeay32.dll and ssleay32.dll in the current working directory of your application or in your PATH. DONE
In your .NET project, add a reference to the ManagedOpenSsl.dll assembly. DONE

I have put libeay32.dll and ssleay32.dll in both my bin/Debug and bin/Release directories. I have also put them in system32.

Here is my FULL code:

using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                OpenSSL.Crypto.RSA rsa = new OpenSSL.Crypto.RSA();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.InnerException.Message);
            }
            Console.Read();
        }
    }
}

I get the following error: Unable to load DLL 'libeay32' http://localhostr.com/files/a719c5/Error.gif (Unable to load DLL 'libeay32')

Here is the Process Monitor log (upon request): alt text http://localhostr.com/files/726a46/ProcMon.gif

What am I doing wrong? Why isn't the DLL found?

12条回答
迷人小祖宗
2楼-- · 2019-01-18 13:24

As a last resort, if nothing else works:

It may be useful to know where the application (.net or not) is looking for the DLLs. Just use Process Monitor and filter for the file name of the DLL. Then copy it to a location where the application is looking for it.

查看更多
甜甜的少女心
3楼-- · 2019-01-18 13:31

In my case, when we develop a web site with open ssl on x64 win 2008 platforms, we must check with application pool : allow 32 applications : true

enter image description here

查看更多
再贱就再见
4楼-- · 2019-01-18 13:33

Try changing the Platform target for your project to x86 instead of "any cpu".

查看更多
时光不老,我们不散
5楼-- · 2019-01-18 13:38

I found a solution.

Unfortunately the VS2008 C++ Redistributable package didn't work - I had to install the SP1 version AND VC++2008. The author said in a comment on its website that it was a mistake on its side, and not mine. He is currently recompiling the DLLs to be statically linked. Thank you to all of those who helped me :)

查看更多
forever°为你锁心
6楼-- · 2019-01-18 13:41

Your problem is related with this question:

DllNotFoundException, but DLL is there

Verify if all depencencies are in same folder of your application or are registred.

查看更多
手持菜刀,她持情操
7楼-- · 2019-01-18 13:44

For anyone else out there still experiencing this issue (and have verified that the necessary prerequisites exist in their correct locations:

Check the OpenSSL.NET installation documentation and ensure its prerequisites are installed. In my case, a user was missing the Microsoft Visual C++ 2010 Redistributable Package (x86) dependency which is called out in the OpenSSL.NET documentation.

查看更多
登录 后发表回答