Dotnet core run as 32bit 86x on Linux

2.2k views Asked by At

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

2

There are 2 answers

2
b2f On

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

dotnet publish --runtime linux-x86 sampleProject.csproj
0
pvenky On

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.