I have a C# console app written under net 6.0. And I ran it complied exe file (I complied it in Windows and upload whole published folder to Linux VM) using mono, and get following message:
file does not contain a valid CIL image.
I checked the other thread and re-install dotnet package. But it still does not work out.
Please provide some help. Thanks.
2
Answers
I finally found the answer:
dotnet program.dll
(exe file is not working here)
Thanks for you guys' help.
.NET 6 is not compatible with Mono, so if you want your .NET 6 console app to run on Linux, you should need to strictly follow the .NET Core/.NET 6 guides,
Running a self-contained ASP.NET Core application on Ubuntu
The "complied exe file" generated for a .NET 6 console app by
dotnet publish
, is strictly a native Windows executable (equivalent of .NET CLI executable) that contains no MSIL. That’s why when you force Mono runtime to load it "file does not contain a valid CIL image" is reported. Don’t check any other threads, as Mono is going away and not what you should resort to at this moment, https://halfblood.pro/the-end-of-mono/