C# compiler: /nostdlib option

て烟熏妆下的殇ゞ 提交于 2019-12-05 04:33:47

Yes, it is used by anybody that compiles a program that doesn't run with the desktop version of the CLR. Like Silverlight, it targets .NETCore, or the Micro Framework. They have their own mscorlib.dll, of course with System.Object defined.

Here's the compiler command line of a sample Silverlight project:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Csc.exe /noconfig /nowarn:1701,1702 
/nostdlib+ /errorreport:prompt /warn:4 /define:DEBUG;TRACE;SILVERLIGHT
/reference:"c:\Program Files\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\mscorlib.dll" 
  etc...

According to the docs

http://msdn.microsoft.com/en-us/library/fa13yay7(VS.80).aspx

You use it if you are trying to replace the System classes.

You may also want to use it if you want to build to deploy against an older framework version. Visual Studio (15, anyway) uses this option when building a project that you configured to target an older framework version. Instead of using the standard mscore, it uses one from Reference Assemblies/Microsoft/Framework/vx.y

From MSDN - "Use this option if you want to define or create your own System namespace and objects.". Fair enough - I won't be doing that any time soon, tho'. :)

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