你可以编译C#,因此并不需要在运行时.NET框架? [英] Can you compile C# so it doesn't need the .NET Framework at runtime?

查看:183
本文介绍了你可以编译C#,因此并不需要在运行时.NET框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能迫使C#编译器拉出框架的所有引用调用,打包成dll文件,甚至一个可执行文件?

Is it possible to force the C# compiler to pull all the referenced calls out of the framework and pack them into dlls or even a single executable?

我喜欢写快一次性应用程序用C#,但是我不希望有在目标计算机上安装整个框架一旦它已经准备好去。

I like writing quick 'one-off' applications with C#, however I don't want to have to install the whole framework on the target machine once it's ready to go.

推荐答案

你问一个加载的问题。 C#是只是一种语言并不需要.net框架。其编译的过程需要一个编译器,它可能会或可能不会自行承担.NET框架的依赖(微软的C#编译器不 - 它是用天然code)。你的程序将需要引用一些程序集,其中的类型,类和方法可以找到供您使用。您的可以的从你的推荐名单中删除system.dll中和的mscorlib.dll,并引用您自己的程序集。这样就可以避免在.NET Framework的依赖性,如果你脚踏实地地去做。但最后,除非你有一个C#编译器编译程序本土code你仍然对CLR的依赖。

You ask a loaded question. C# is merely a language and does not require the .NET Framework. The process of compiling it requires a compiler, which may or may not itself take a dependency on the .NET Framework (Microsoft's C# compiler does not -- it is written in native code). Your program will need to reference some assembly where types, classes, and methods can be found for your use. You can remove system.dll and mscorlib.dll from your references list and reference your own assemblies. So you can avoid dependencies on the .NET Framework if you really work at it. But in the end, unless you have a C# compiler that compiles programs to native code you still have a dependency on the CLR.

这就是说......几乎没有一个非常技术性的方法。但它回答你的问题。 :)更实际有用的不过是如何让你的C#程序用最少的依赖运行。从单声道mkbundle实际上将让你几乎没有依赖编译所有到.exe。

That's a very technical way of saying... almost nothing. But it answers your question. :) More practically useful however is how to get your C# programs to run with a minimum of dependencies. mkbundle from mono will actually let you compile it all into an .exe with virtually no dependencies.

但是,如果你要坚持使用微软.NET框架,可以实现轻得多的足迹和更快地安装您通常需要使用的.NET 3.5 SP1的客户端配置文件之间的依赖关系。你可以在这里阅读有关: <一href="http://msdn.microsoft.com/en-us/library/cc656912.aspx">http://msdn.microsoft.com/en-us/library/cc656912.aspx

But if you want to stick with the Microsoft .NET Framework, you can achieve a much lighter footprint and faster install of the dependencies you commonly need by using the Client profile of .NET 3.5 SP1. You can read about it here: http://msdn.microsoft.com/en-us/library/cc656912.aspx

这篇关于你可以编译C#,因此并不需要在运行时.NET框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆