Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I'm trying to control RFID reader on linux using Dotnet core 3

ReaderDynamicLib.dll is main controller file which is not my created dll file. It is manufacture provided sdk file runs on only 32bit I tried it in windows.

I created console application to send parameter to ReaderDynamicLib.dll

   [DllImport("ReaderDynamicLib.dll")]
public static extern int SetAntenna(int hScanner, int m_antenna_sel, int Address);

like this runs fine on windows but in linux

  An attempt was made to load program with an incorrect format

I assume linux don't have run as 32bit option

It's probably irrelevant now, but for future reference, the problem here is that the vendor dll was likely compiled to work on Windows platform (since you are able to run it on Windows). You cannot then DllImport the exact same library into a .NET program running on linux. A binary that is native-compiled to work on the Windows platform will not load on the linux platform. It will have to be recompiled targeting linux.

I don't know anything about your project, but publishing for linux 32 bit should work with

dotnet publish --runtime linux-x86 sampleProject.csproj
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.