Installing / compiling .NET binding problems.

956 views
Skip to first unread message

RichieG

unread,
Dec 10, 2016, 11:46:16 PM12/10/16
to automatak-dnp3
OK, I've been struggling getting this to work for the past couple of days, so I've finally gave up and had to ask for help!

My machine is Windows 10 (64 bit), using Visual Studio 2015.

I've installed CMake, and I clone the dnp3 repo recursively to C:\libs\dnp3\ so I don't have to worry about ASIO.

I've installed OpenSSL-32 via Shining Light (since I figured I'd be making a 32bit application, I've also tried 64 bit but that seemed to throw more errors).

I've also set my Environment variables to the following:

OPENDNP3_DIR: C:\libs\dnp3\build\lib
OSSL_LIB32_DIR : C:\OpenSSL-Win32\lib\VC\static

Then I run the Build-Dotnet.bat.

It always fails when it gets to compiling the bindings.

The results are here: http://pastebin.com/ZXWXK5Hi

Any help would be appreciated, I'm going around in circles at the moment.






RichieG

unread,
Dec 11, 2016, 4:59:48 PM12/11/16
to automatak-dnp3
To give some background to this question, I don't actually need to edit the .NET bindings or the opendnp3 C++ code. 

I just want to run OpenDNP3 as a Nuget provided package in my application. 

I get the "System.BadImageFormatException: Could not load file or assembly 'DNP3CLRAdapter.dll' or one of its dependencies" error, which I've seen in other threads seems to be related to OpenSSL.

Do I need to have opendnp3 compiled somewhere on my PC to use the Automatak.DNP3.Adapter & Interface?



J Adam Crain

unread,
Dec 11, 2016, 6:07:55 PM12/11/16
to automatak-dnp3
Hi Richie,

DNP3CLRAdapter.dll is a mixed-mode assembly that contains the full opendnp3 C++ library inside of it.

Usually the expection the you mention is because on of these two dependencies can't be located:

1) The visual c++ runtime

If you're on a machine that has VS 2015 installed, I'd be surprised if this was the problem. Otherwise you can download it here for deployment machines:


2) Openssl libraries

You can either put libeay32/libssleay32 in the directory along with the .NET dnp3 assembly or a in system location.

I'll have a look at the .NET build script tomorrow.

-Adam

J Adam Crain

unread,
Dec 12, 2016, 10:48:54 AM12/12/16
to automatak-dnp3
So it looks like build-dotnet.bat is in fact broken.

Sid, do you guys actually use this as part of your environment? Now that we have an appveyor build that creates Nuget packages, can we dispense with this script?

I usually open the .NET solution manually when developing.

-Adam

Sid Hoda

unread,
Dec 21, 2016, 5:14:28 PM12/21/16
to automatak-dnp3
Yes, although the benefit is more that it does cmake, build c++ and install in one step more so than building the .NET bindings. I usually run the script prior to then opening the .NET solution. Ideally we'd keep and fix the script If possible.

What I don't understand is why the script would fail when VS2015 doesn't. I'm wondering if it is either target platform mismatch or missing OPENDNP3_DIR environment variable? I'll see if I can find some time tomorrow to track down the issue.

Sid

Sid Hoda

unread,
Dec 21, 2016, 5:17:05 PM12/21/16
to automatak-dnp3
Just to clarify, we actually use the nuget.org package in our environment. However, when doing local development or debugging I'd use the build-dotnet script.

Sid

Jack Whitehead

unread,
Jan 9, 2017, 10:54:20 AM1/9/17
to automatak-dnp3
Hi guys,

Just started working with this library and I'm having a similar problem to Sid.
I've combed through the group and tried to apply everything I've found so I'll summarize below and hopefully someone can tell me where/if I'm going wrong.

I'm using the nuget package (I've tried with the stable and latest release) in the hopes of removing most of the self build requirements.

Developing in C# under Visual Studio 2015 Enterprise on Windows 7.
I've set all projects in the solution to compile in x86 configuration.

I have the following Visual C++ Redistributable packs installed:
2008 x64 9.0.30729.17
2008 x64 9.0.30729.4148
2008 x64 9.0.30729.6161

2008 x86 9.0.30729.4148
2008 x86 9.0.30729.4974
2008 x86 9.0.30729.6161

2010 x64 10.0.30319
2010 x86 10.0.40219

2013 x64 (No version...?)

2015 x64 14.0.24210
2015 x64 14.0.24212
2015 x86 14.0.24215

I've installed Shining Light OpenSSL for Windows version 1.0.2.j (32 bit) and copied libeay32/libssleay32 into the directory where my executing assembly is starting from (next to the DNP3CLRAdapter.dll and DNP3CLRInterface.dll)

With all this I'm still getting the following exception: Could not load file or assembly 'DNP3CLRAdapter.dll' or one of its dependencies. The specified module could not be found.

Any thoughts or hints from anyone on how to debug this?

Regards,
Jack

Adam Crain

unread,
Jan 9, 2017, 11:01:04 AM1/9/17
to automatak-dnp3
Hi Jack,

Can you try compiling without openssl support just so we can see if the problem is w/ dynamically linking openssl or just the base library?

The directions for compilation are here:

https://www.automatak.com/opendnp3/docs/guide/current/build/windows/

-Adam

Jack Whitehead

unread,
Jan 10, 2017, 5:25:39 AM1/10/17
to automatak-dnp3
Adam,

Good suggestion, that got it working.
Do you think it was a compatibility issue with the OpenSSL version I had? Or a C++ compiler version problem?

Either way I'm online now and ready to start testing. This library is great, so easy to get going. Thanks for the hard work!

Regards,
Jack

J Adam Crain

unread,
Jan 16, 2017, 10:43:19 AM1/16/17
to automatak-dnp3
I'm not sure. Getting pre-compiled versions of openssl for windows that match the required C++ runtime version has been an issue.

-Adam

İlker EKER

unread,
Oct 17, 2017, 5:09:46 AM10/17/17
to automatak-dnp3
Hi Jack,

Have you achieved to compile succesfully? I am also having trouble in compilation. Dll. files are not forming?

İlker EKER

unread,
Oct 17, 2017, 5:11:33 AM10/17/17
to automatak-dnp3
Hi Adam,
I am also having trouble in C# compilation. Can you suggest a version for OpenSSL?
Thanks.
Reply all
Reply to author
Forward
0 new messages