Can c# compiled app run on machine where .net is not installed?

会有一股神秘感。 提交于 2019-12-20 01:35:06

问题


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.



来源:https://stackoverflow.com/questions/887016/can-c-sharp-compiled-app-run-on-machine-where-net-is-not-installed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!