-1

I am new to dotnet platform. I have a c# app prebuilt in windows and i wanna run it in linux (Centos-7 x64) on dotnetcore (3.1) platform. I think this app can run directly on dotnetcore (linux) without doing the extra effort.

But when I run it on command line as below, I got "cannot execute binary file".

$./app.exe

Extra: i also installed mono platform for totally experimental and i use xbuild to build win-apps sln on linux platform successfully. But again i got the same error when i run app on linux.

My dotnet is:

dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.1.300
 Commit:    b2475c1295

Runtime Environment:
 OS Name:     centos
 OS Version:  7
 OS Platform: Linux
 RID:         centos.7-x64
 Base Path:   /usr/share/dotnet/sdk/3.1.300/

Host (useful for support):
  Version: 3.1.4
  Commit:  0090613580

.NET Core SDKs installed:
  3.1.300 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.1.4 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.4 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

Could you help me with this?

Thanks.

aphelix
  • 29
  • 1
  • 4
  • try running "dotnet app.exe" – Josh May 21 '20 at 09:01
  • windows and linux platforms are all 64 bits. (Windows 10 & centos7-64) – aphelix May 21 '20 at 09:01
  • _"I think this app can run directly on dotnetcore (linux) without doing the extra effort."_ ...no, that's not true, neither for for .NET or for any other language or framework). A Windows executable is a totally different type of file from a Linux executable. https://stackoverflow.com/a/46861681/5947043 might help you - you have to build for the target platform specifically. The tutorial https://learn.microsoft.com/en-us/dotnet/core/tutorials/cli-create-console-app also says "When the app is compiled, an **operating system-specific executable** was created". – ADyson May 21 '20 at 09:07
  • And see also https://learn.microsoft.com/en-us/dotnet/core/deploying/#produce-an-executable - it says very clearly: "Executables aren't cross-platform. They're specific to an operating system and CPU architecture" . It helps to always read the documentation before spending your time on something which will never work... you need to build your application again for the platform you want to run it on. – ADyson May 21 '20 at 09:09

1 Answers1

2

"exe" files are not executable in Linux environments.

To run your application run dotnet <project name>.dll

Stelios Giakoumidis
  • 2,153
  • 1
  • 7
  • 19