C#编译器:/ nostdlib选项

Mar*_*son 7 .net c# mscorlib

在编译时,如何才能将stdlib(mscorlib.dll)包含到我的C#应用​​程序中?据我所知,所有类都继承System.Object类,该类在mscorlib.dll中定义.更重要的是 - 诸如int之类的类型只是例如System.Int32的别名,它们也在mscorlib中定义.这个选项曾经使用过吗?

Han*_*ant 10

是的,编译程序不能与CLR的桌面版本一起运行的任何人都可以使用它.与Silverlight一样,它的目标是.NETCore或Micro Framework.他们有自己的mscorlib.dll,当然定义了System.Object.

这是Silverlight项目示例的编译器命令行:

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...
Run Code Online (Sandbox Code Playgroud)