Can I create a Win32 app in C#?

Asked

Viewed 143 times

3

I am aware that C# is . NET Framework’s right-hand man, and that the default language for programming Win32 applications is C++. But, I can program an application in C#, independent of any . NET Framework library?

In other words, I can create an application entirely written in C#, which does not use no . NET Framework library, so that it can be executed using only the Runtime Windows, not . NET Framework?

  • 1

    Just to confirm: you want to create an executable, right? So the answer is yes. Just open the visual studio , create a new project , choose the windows template and then windows Forms Applications. From there is programming from there.

  • Not exactly, want to create an application that does not depend on the . NET Framework to run.

1 answer

6


Being independent of . NET Framework is different from being independent of anything.

It is possible to create a native executable using C# or other standard language. NET with .NET Native. It is a set of tools that allows you to convert the CIL for native platform binary. Of course it has a library that acts as the Runtime of the language that is needed. By C# requirement this Runtime It can’t be that small, but it’s much smaller than the . NET Framework and can get all contained within the native executable itself *has some tricks that can be done, can make keep 4KB, but subvert what C really is#).

This requirement to have nothing else can only be met by Assembly in more or less C, yet doing something very basic. Understand how . NET works. You can reduce part of the infrastructure, but you can’t eliminate everything without making it impossible to be what it is, to give the security normally offered.

Nor can it function without several of the BCL classes. The language supports many of them and even those that are not directly dependent on the language are still used in most applications. Of course a self-contained executable need not have more than the code used, need not load all BCL or FCL. Same in every language. Even C depends on a library. I just can’t tell if it’s smart enough to separate what you use in each class or need to put it all, or even every compilation unit if it’s a Linker. There’s a case you can’t even risk eliminating certain things.

Of course some features can be compromised without the full platform. Reflection even is a little limited, but in native executable it has little use even.

Also has the LLILC using LLVM.

There are other ways to use the middle where you don’t need the . NET Framework installed on the machine, but it’s not enough to be a native executable either. Could be the .NET Core, the Mono, some models of Xamarin. In iOS Xamarin generates native code. All of them are independent of the . NET Framework or other platform that needs to be previously installed.

The . NET Framework is just one of the ways to serve C#, and is going into disuse, including . NET Native does not have much future, a pity.

  • But I can create an application independent of . NET Framework entirely made in C#? Is that possible? In other words, compile a Win32 executable (not .NET Framework) directly from a C code#?

  • 1

    You can with . NET Native.Of course you will always have one Runtime What virtually every language has, C# requires a little bit of a bit of a bit, but it doesn’t require a bit of a component. NET Core is halfway through. It has a component that makes everything work without needing anything installed, but it is not a native executable. Mono has always been like this. Xamarin has more than one model.I think now I understand what you asked, how you used the incorrect term I thought you wanted something else.

  • I think so too, but your answer complements on the iteration of . NET with Win32 and I find this very useful, I will update my question so you can understand better.

  • 1

    The original answer that was not what the PA wanted is in https://answall.com/q/227656/101.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.