I’m trying to run a C# application in a ubuntu Docker container with mono. The application runs correctly in a windows environment. I just copied all the directories to the docker volume.
I can build the application using the following command without errors or warnings:
msbuild CSharpSampleLSV2.csproj /t:Rebuild /p:Configuration=Release /p:Platform=”x86″
But when I try to run the application using the following command:
MONO_LOG_LEVEL=debug mono CSharpSampleLSV2.exe
I’m getting some errors like this:
Mono: DllImport error loading library ‘P_LSV2.DLL’: ‘P_LSV2.DLL: cannot open shared object file: No such file or directory’.
I don’t understand why I get this errors. The libraries are located in the same place than in the windows environment.
If more information is needed I’ll provide it.
Advertisement
Answer
Extension “.dll” of P_LSV2.DLL
library mentioned in exception hints that this is windows-specific native library you are trying to pinvoke too (DllImport
suggests pinvoke). Linux native libraries almost always have extension “.so”. So you are trying to invoke something from native library compiled for windows while you are on linux – this isn’t going to work.
.NET compiles into IL (Intermediate Language) and that language is then compiled at runtime into native code for platform this code is executing at. In contrast to that – native library contains already compiled code for target platform. So using native library compiled for windows platform is not possible on linux.
So you need to grab that library compiled for linux somewhere. If such version is not available and source code is also not available (from source code you can try to compile for linux, though this might be not easy) – you are out of luck.