-->

Can c# compiled app run on machine where .net is n

2020-04-10 00:40发布

问题:

I want to develop a small utility for windows and I prefer doing that in c# because it is easier (I'm a java developer).

The utility will be available for download by many people and I assume some of them will not have the .net framework installed (is this assumption correct, say I target win xp and above?)

My question is: can a c# application be compiled in a way that it will not require the .net framework installed?

回答1:

Normally, you will need the .NET Framework being installed on the target system. There is no simple way around that.

However, certain third-party tools such as Xenocode or Salamander allow you to create stand-alone applications. See this related question:

Is there some way to compile a .NET application to native code?

As these solutions are not straight-forward and require commercial products I would recommend you to create a simple Visual Studio Setup and Deployment project. In the properties of the project you should include the .NET Framework as a pre-requisite. The setup.exe created will then automatically download and install the .NET Framework prior to installing your application.



回答2:

No, it will need the .Net framework installed. Note though that you will need only the redistributable version, not the SDK.



回答3:

A minor aside - but in this scenario, consider developing the utility in Silverlight - it has a much smaller footprint and is supported on a number of operating systems. This might allow you to get the coverage including people who don't already have .NET.

If you need "normal" .NET, then "Client Profile" is perhaps an option.



回答4:

You can probably also include the .net framework installer in your application.



回答5:

In a related question, Can you compile C# without using the .Net framework?, it's mentioned you could do this using mkbundle from mono. I haven't tried it myself so I can't comment on if it's the way you should go, but you may want to consider it.