简体   繁体   中英

c# exe file example

Can someone give me an example of how I can create an exe file with no dependencies from a console app project?

I know that in bin/debug I will have the exe file after compiling my code. I would like to know how can i make an exe that will run on every computer without the need to install Visual Studio (or any other dependency: eg .net framework) on that particular computer. Is it possible?

Is there a better way to create .exe files that run on every computer?

The user doesn't have to install Visual Studio in order to use an app built in C#. They do have to have the .NET framework installed, however.

Modern versions of Windows have come with .NET preinstalled for a while, and they've been part of Windows update, too - obviously the earlier the version of .NET you target, the more computers you're likely to be able to run on. I expect that targeting .NET 2.0 should give pretty good coverage, although that way you miss the goodies from LINQ etc.

While there are "native" compilers for .NET, I don't know of any mainstream ones... the Mono AOT is probably the closest to mainstream, but I haven't used it myself.

If you write it c# the machines you need will need .net on.

Only way to write apps that dont is either, to investigate specialised packaging tools that will install and take the bits of .net you need with it, or, write a native app

您至少需要编译器才能生成可执行文件。

You have two options to create a windows application (an exe):

  • Managed .NET applications: You don't need VS in the target machine but you need de .NET runtime. You can include it making an installation package or just include the url for your users to install it manually.
  • Native applications: They run in any Windows computer but are harder to develop. Typically you have to use C/C++ instead of C#/.NET.

In the bin folder (debug or release - it depends on your compilation configuration) you have compiled program that you can take (will all dll's that are in this folder) to another computer. Because you use C# (and generally .Net) as you programming language to run this program .Net framework has to be installed on the machine you want to use this app - this is requirement.

On every machine? Do u mean pc (windows, linux, unix), mac etc? U have to use multiplatfor leangue like Java orac C/C++.

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