Compile to a stand-alone executable (.exe) in Visual Studio

前端 未结 7 1731
囚心锁ツ
囚心锁ツ 2020-11-30 04:36

how can I make a stand-alone exe in Visual Studio. Its just a simple Console application that I think users would not like to install a tiny Console application. I compiled

相关标签:
7条回答
  • 2020-11-30 05:04

    I've never had problems with deploying small console application made in C# as-is. The only problem you can bump into would be a dependency on the .NET framework, but even that shouldn't be a major problem. You could try using version 2.0 of the framework, which should already be on most PCs.

    Using native, unmanaged C++, you should not have any dependencies on the .NET framework, so you really should be safe. Just grab the executable and any accompanying files (if there are any) and deploy them as they are; there's no need to install them if you don't want to.

    0 讨论(0)
  • 2020-11-30 05:06

    Anything using the managed environment (which includes anything written in C# and VB.NET) requires the .NET framework. You can simply redistribute your .EXE in that scenario, but they'll need to install the appropriate framework if they don't already have it.

    0 讨论(0)
  • 2020-11-30 05:07

    If I understand you correctly, yes you can, but not under Visual Studio (from what I know). To force the compiler to generate a real, standalone executable (which means you use C# like any other language) you use the program mkbundle (shipped with Mono). This will compile your C# app into a real, no dependency executable.

    There is a lot of misconceptions about this around the internet. It does not defeat the purpose of the .net framework like some people state, because how can you lose future features of the .net framework if you havent used these features to begin with? And when you ship updates to your app, it's not exactly hard work to run it through the mkbundle processor before building your installer. There is also a speed benefit involved making your app run at native speed (because now it IS native).

    In C++ or Delphi you have the same system, but without the middle MSIL layer. So if you use a namespace or sourcefile (called a unit under Delphi), then it's compiled and included in your final binary. So your final binary will be larger (Read: "Normal" size for a real app). The same goes for the parts of the framework you use in .net, these are also included in your app. However, smart linking does shave a conciderable amount.

    Hope it helps!

    0 讨论(0)
  • 2020-11-30 05:08

    Inside your project folder their is a bin folder. Inside your bin folder, there are 2 folders, a Release and a Debug. For your polished .exe, you want to go into your Release folder.

    I'm not quite sure if thats what youre asking

    0 讨论(0)
  • 2020-11-30 05:15

    You can embed all dlls in you main dll. See: Embedding DLLs in a compiled executable

    0 讨论(0)
  • 2020-11-30 05:19

    I don't think it is possible to do what the questioner asks which is to avoid dll hell by merging all the project files into one .exe.

    The framework issue is a red herring. The problem that occurs is that when you have multiple projects depending on one library it is a PITA to keep the libraries in sync. Each time the library changes, all the .exes that depend on it and are not updated will die horribly.

    Telling people to learn C as one response did is arrogant and ignorant.

    0 讨论(0)
提交回复
热议问题