Search code examples
c#shared-librariesstreamingdata-sciencebadimageformatexception

How to get lab streaming layer to work in C#?


I have a device that records live data like eeg measurements. I want to send these data with a lab streaming layer (lsl). Unfortunately I'm unable to configure the lsl and get it to run. I'm not sure if I even copied the dll to the right places.

What I did so far:

  • downloaded recent lsl dll from latest release page

  • copied the liblsl64.lib and liblsl64.dll to my project folder and the Debug folder of my project

  • copied LSL.cs (from github as described in C# Bindings) into my project: renamed const string libname = "lsl"; to const string libname = "liblsl64";

  • when I run the code:

    liblsl.StreamInfo info = new liblsl.StreamInfo("TestCSharp","EEG");

I get a System.BadImageFormatException: HRESULT: 0x8007000B

Can anyone help me with this?


Solution

  • I get the System.BadImageFormatException, because I have "Any CPU" instead of "x64" in my configurations manager. It also works when using a .Net Core application for accessing the library.