Apollo3zehn / EtherCAT.NET

A high-level SOEM-based EtherCAT master with ESI support for Windows and Linux.
GNU Lesser General Public License v3.0
177 stars 53 forks source link

Bad Image Format Exception #65

Closed SilentCoyote closed 3 years ago

SilentCoyote commented 3 years ago

Hi,

Having cloned the github project and executed the powershell script as per the instructions for building from source on Windows, when trying to run the sample program I get a BadImageFormatException (System.BadImageFormatException: 'An attempt was made to load a program with an incorrect format. (0x8007000B)') at the call to EcHL.CreateContext() in the ScanDevices method of ECUtilities.

Stack trace: at SOEM.PInvoke.EcHL.CreateContext() at EtherCAT.NET.EcUtilities.ScanDevices(String interfaceName, SlaveInfo referenceRootSlave) in D:\Projects\VisualStudio\EtherCAT.Net\src\EtherCAT.NET\EcUtilities.cs:line 290 at SampleMaster.Program.

d__0.MoveNext() in D:\Projects\VisualStudio\EtherCAT.Net\sample\SampleMaster\Program.cs:line 51

Operating system is Windows 10 x64, trying to run Debug, Any CPU build and WinPcap is installed. I've noticed the soem_wrapper.dll in artifacts\bin\SampleMaster\Debug\net50 is reporting 0KB size.

Any help would be appreciated!

Apollo3zehn commented 3 years ago

I am answering from my phone so I can't check the details, but BadImageFormatException also occurs why trying to load an x64 binary in 32 bit mode or vice versa. But loading an empty file could maybe also raise this exception.

Did compiling the native libraries work (see README)? Did the powershell script finish successfully?

Am 19. August 2021 13:54:09 MESZ schrieb SilentCoyote @.***>:

Hi,

Having cloned the github project and executed the powershell script as per the instructions for building from source on Windows, when trying to run the sample program I get a BadImageFormatException (System.BadImageFormatException: 'An attempt was made to load a program with an incorrect format. (0x8007000B)') at the call to EcHL.CreateContext() in the ScanDevices method of ECUtilities.

Stack trace: at SOEM.PInvoke.EcHL.CreateContext() at EtherCAT.NET.EcUtilities.ScanDevices(String interfaceName, SlaveInfo referenceRootSlave) in D:\Projects\VisualStudio\EtherCAT.Net\src\EtherCAT.NET\EcUtilities.cs:line 290 at SampleMaster.Program.

d__0.MoveNext() in D:\Projects\VisualStudio\EtherCAT.Net\sample\SampleMaster\Program.cs:line 51

Operating system is Windows 10 x64, trying to run Debug, Any CPU build and WinPcap is installed. I've noticed the soem_wrapper.dll in artifacts\bin\SampleMaster\Debug\net50 is reporting 0KB size.

Any help would be appreciated!

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/Apollo3zehn/EtherCAT.NET/issues/65

Apollo3zehn commented 3 years ago

I got an hint that the Nuget package is also not working and containing a 0 kB file. I will check the build process tomorrow morning.

Apollo3zehn commented 3 years ago

Should be fixed now (nuget package and all branches). I´ll close this for now. If the problem persists, please tell me.