Unable to load the nuget provided .NET bindings (2.1.0 RC6)

554 views
Skip to first unread message

Thomas Speckert

unread,
Apr 11, 2016, 11:41:43 AM4/11/16
to automatak-dnp3
Hello,

I'm having some difficulties using the Nuget-provided .NET bindings. Building myself (VS2013), everything works perfectly. The only difference I can think of, is that I built them with openssl statically linked, whereas the nuget package has them dynamically linked.

I get the following exception upon attempting to load them when built as Win32/x86:

System.BadImageFormatException: Could not load file or assembly 'DNP3CLRAdapter.dll' or one of its dependencies. The operating system cannot run . (Exception from HRESULT: 0x800700B6)
File name: 'DNP3CLRAdapter.dll'

I also get the same exception upon attempting to load them when built as "Any CPU" (which seems to be how both DNP3CLRAdapter and DNP3CLRInterface are compiled).

My original thought was that it wasn't finding openssl, but I do have the shining light version installed (x64 and x86 both). I've tried copying the openssl DLLs to my executable directory, but this doesn't change anything either.


Best regards,

Tom

J Adam Crain

unread,
Apr 11, 2016, 12:30:30 PM4/11/16
to automatak-dnp3
Hi Tom,

I was just able to build and run the simulator project from the latest (2.1.0-RC6).

A couple of tips.

Always set your build type for your executable to "x86" not any CPU. I place the 32-bit libesy32.dll and libssl32.dll in the C:\System\SysWow64 folder

You'll get warnings when building like the following if any library/exe that depends on the Nuget package doesn't also adopt a Platform setting of x86.

 "warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "DNP3CLRAdapter, Version=1.0.5942.30511, Culture=neutral, processorArchitecture=x86", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project."

I build against openssl with dynamic linking simply because I don't want to re-release opendnp3 after every openssl security advisory.

-Adam

Thomas Speckert

unread,
Apr 12, 2016, 8:01:38 AM4/12/16
to automatak-dnp3
Seems to be working now, but I honestly have no clue what I changed. I can no longer even recreate the problem, despite my best efforts :P

Does not seem to have been openssl related, as I can completely remove it or even install the wrong version without any issues.

Thank you,
Tom

jithend...@gmail.com

unread,
Feb 26, 2018, 7:19:14 PM2/26/18
to automatak-dnp3
Adam,

I am devloping a simulator using .NET frameowrk and using the OpenDNP3 v2.2.0 nuget package. Everything works fine for x86 build. When I am trying to build a 64-bit executable, I have the following warning,

"warning MSB3270: There was a mismatch between the processor architecture of the project being built "AMD64" and the processor architecture of the reference "DNP3CLRAdapter, Version=1.0.6396.24860, Culture=neutral, processorArchitecture=x86", "x86". 
This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, 
or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project."

Initially I ignored this warning and installed the 64-bit OpenSSL (v1.0.2n) from shinelight and copied the libeay32.dll, libssl32.dll to the project folder assuming it would work anyway. But it complained it that cannot find the dependency. So I am assuming
the DNP3CLRAdapter's CPU archiecture is still x86 and it is probably looking for 32-bit OOpenSSL libraries.
  
Is it possible to change the processorArchitecture of the dll to 64-bit somehow? Or should I build the library manually for 64-bit using cmake and import to the project? If so should I switch between libraries to make a build (32-bit and 64-bit) everytime

I know this is not a dnp3 question, but I thought you might have some idea on this if incase you built any 64-bit simulators previously.

Thanks for any assitance you might have for me. 

-Jithendar

J Adam Crain

unread,
Mar 5, 2018, 10:12:04 PM3/5/18
to automatak-dnp3
Hi Jithendar,

The nuget package is 32-bit only.

If you need a 64-bit assembly, you have to build manually ATM. We might consider having 2 separate Nuget packages...

The C++ build and the .NET have to match architectures. You can tell the build where the 64-bit openssl libraries are located using environment variables:


-Adam
Reply all
Reply to author
Forward
0 new messages