4

Native exe! that means my program can run easily without any requirement? even if I use .net classes?

You know I want to write a program that is so light and I don't like to use C# or any other .net programing language because all of them need .net-framework 4.5.

Just think a 2.5 MB programm needs a +250 MB .netframework.

New Update - 12/01/2016:

It's almost 4 years ago when I asked this question. As you know Dotnet Native is announced. It's an interesting feature which compile IL into native code.

Compiling Apps with .NET Native

.NET Native is a precompilation technology for building and deploying Windows apps that is included with Visual Studio 2015. It automatically compiles the release version of apps that are written in managed code (C# or Visual Basic) and that target the .NET Framework and Windows 10 to native code. Typically, apps that target the .NET Framework are compiled to intermediate language (IL). At run time, the just-in-time (JIT) compiler translates the IL to native code. In contrast, .NET Native compiles Windows apps directly to native code. For developers, this means:

  • Your apps will provide the superior performance of native code.
  • You can continue to program in C# or Visual Basic.
  • You can continue to take advantage of the resources provided by the .NET Framework, including its class library, automatic memory management and garbage collection, and exception handling.
Ali Bahrami
  • 5,935
  • 3
  • 34
  • 53
  • possible duplicate of [What programming language should I use to create small, native Windows Applications?](http://stackoverflow.com/questions/2711599/what-programming-language-should-i-use-to-create-small-native-windows-applicatio) – gbjbaanb Dec 25 '10 at 14:28
  • A native exe does not use .NET classes. It can use COM servers written in .NET, but naturally those require the .NET Framework to be installed. – Ben Voigt Dec 25 '10 at 14:42

3 Answers3

2

Last I checked none of the .NET frameworks were 250+ MB! Yes, the offline installer for .NET Framework 3.5 SP1 is 231MB but it contains x86 and x64 versions of .NET 2, 3 and 3.5 sp1.

You should read this http://www.smallestdotnet.com for details on sizes of various versions of the installers.

Now on to your question:
Yes, It is a little annoying to have your clients install a big framework, even 20-40MB does get annoying. With .NET, the advantage is the ease of programming (In my opionion) compared to other Native options.

Your native options are:
MFC - You need only the VS runtimes installed, which is 1-2MB and is usually installed on newer pcs. Also, you can ship your application with the MFC libraries packaged into a dll which is again <2MB

The trade of here is you need to program in C++, the libraries overall are a very thin layer over the native libraries. and people have had harsh opinions about MFC. I've barely just tried it.

Win32 API - This is going all bare bones, and quite difficult, you could use C or C++ but you'd really have to know a lot about the Win32 API and how windows itself works (Stuff like windows messages, hwnds etc) Its not fun, believe me. But during deployment you would not need any external libraries.

There are tons more options, see here:
Native Windows Application Development Options
https://stackoverflow.com/questions/2711599/what-programming-language-should-i-use-to-create-small-native-windows-applicatio

Here are some links on MFC that might help:
Want to learn Windows Programming,some suggestions?
How do I decide whether to use ATL, MFC, Win32 or CLR for a new C++ project?
C++ MFC vs .NET?
https://stackoverflow.com/questions/557114/stick-with-mfc-or-go-to-net

Community
  • 1
  • 1
gideon
  • 19,329
  • 11
  • 72
  • 113
1

you are able to create native exe by using c++ Win 32 projects.

Anton
  • 9,682
  • 11
  • 38
  • 68
1

Alas, nearly everything requires a download runtime library and even if you have one installed, you'll need to download updates for them almost continually. Even Microsoft C++ apps nowadays come with security updates that have to be installed if you've compiled your app with them.

But.. there is a solution of sorts. If you use C++, it has a feature where only the things you use are compiled into the final app. Normally, this would require linking with all the library dlls, but if you statically link with the library, you will end up with a single .exe that is as small as can be, and you will not need any dlls (as all the code contained in the library will be compiled into the .exe).

The benefits are debatable compared to dlls, but as MS has pretty much broken the idea of shared dlls in .NET (ie, you practically have to put all the shared dlls in the same directory as your running app, giving you a nightmare in maintenance if you have these shared dlls spread around all your apps) then there's not much of a difference anymore. Static linking is getting a little bit of a comeback and sounds like its what you want.

For modern C++ development, you'll probably want to take a look at Qt instead of MFC. Its a lot nicer to use and is cross-platform so you can run Qt apps on your Android or Linux platforms as well as Windows.

gbjbaanb
  • 51,617
  • 12
  • 104
  • 148
  • Qt is free (LGPL licenced), check SO for more Qt questions and follow the link; the Qt runtime library is (AFAIK) 9Mb. The entire Qt bin directory is 44Mb including all plugins I have and the 10mb QtWebkit dll. – gbjbaanb Dec 28 '10 at 14:41