简体   繁体   中英

Run dotnet application on Ubuntu 20.04

I am newbie in net core on Linux and i have a question. I installed .net core 5 and wrote hello world app with name "hello". After, I go to the project bin directory and run my app like:

dotnet hello.dll

All fine. But i see "hello" (shared library) file in the bin directory too. I can run it in terminal like:

./hello

All works... But when i copy files in another location (away from project directory), i can't run my app like: ./hello I get message "Segmentation fault (core dumped)" in terminal.

Someone, please, tell me, why after copy files, command "./hello" doesn't work (but dotnet hello.dll works).

Ubuntu 20.04

.NET SDK installed: 5.0.301

.NET runtimes installed: 5.0.7

UPDATE project location:

/RiderProjects/RabbitMq-example/RabbitMq-example/bin/Debug/net5.0

i copy only net5.0 folder to:

/RiderProjects/RMQ/net5.0

And I get Segmentation fault.

If i copy full bin folder (like:

/RiderProjects/RMQ/bin/Debug/net5.0

All fine.

Steps:

  1. Create folder (eg HelloApp)
  2. In folder, open terminal and use dotnet new console
  3. After project creating, use dotnet publish in this folder (bin folder will be create after build action) (By the current step I have RiderProjects/HelloApp/bin/Debug/net5.0/publish)
  4. Copy publish/ folder (with files) to another location (in my case, it is RiderProjects/publish)
  5. dotnet HelloApp.dll in publish folder work perfectly, but ./HelloApp doesn't work

If you installed the dotnet runtime via snap install you can access it via "sudo dotnet ..." only. I had the same problem in VS Code, it runs the dotnet commands without sudo and I recived the "Segmentation fault (core dumped)" error. I solved by installing the dotnet runtime via apt-get (now is installed in "/usr/bin ..." and works without sudo (see: https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#2004- ))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM