编程语言
首页 > 编程语言> > 如何使用C#4.0编译器将MonoDevelop定位到.NET 2.0框架?

如何使用C#4.0编译器将MonoDevelop定位到.NET 2.0框架?

作者:互联网

使用Visual Studio可以轻松实现这一点,尽管我需要使用MonoDevelop来实现这一点,因为Visual Studio编译的DLL在Unity中效果不佳. MonoDevelop DLL可以正常工作,但我想在针对.NET 2.0运行时时使用默认函数参数(C#4.0功能).

MonoDevelop有可能吗?我该如何设置?

添加:为Visual Studio和MonoDevelop构建命令行

我对参数进行了排序以便于比较:

MonoDevelop:目标= Mono / .NET 4

C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe
/noconfig
/warn:4
"/define:TRACE"
/optimize+
"/out:C:\TestLibraries\TestEditor\bin\Release\TestEditor.dll"
/t:library

/nologo

"/r:C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll"
"/r:C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Core.dll"
"/r:C:\Program Files (x86)\Unity\Editor\Data\Managed\UnityEditor.dll"
"/r:C:\Program Files (x86)\Unity\Editor\Data\Managed\UnityEngine.dll"

/fullpaths
/utf8output

MonoDevelop:目标= Mono / .NET 3.5(第一个有趣的例子)

C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe
/warn:4
"/define:TRACE"
/optimize+
"/out:C:\TestLibraries\TestEditor\bin\Release\TestEditor.dll"
/t:library

/nologo
-nostdlib

"/r:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll"
"/r:C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll"
"/r:C:\Program Files (x86)\Unity\Editor\Data\Managed\UnityEditor.dll"
"/r:C:\Program Files (x86)\Unity\Editor\Data\Managed\UnityEngine.dll"

/fullpaths
/utf8output

Visual Studio:目标= .NET 4

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Csc.exe
/noconfig
/nowarn:1701,1702
/warn:4
/define:TRACE
/optimize+
/out:obj\Release\TestEditor.dll
/target:library

/nostdlib+ /errorreport:prompt

/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll"
/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Core.dll"
/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll"
/reference:"C:\Program Files (x86)\Unity\Editor\Data\Managed\UnityEngine.dll"

/debug:pdbonly
/filealign:512

Visual Studio:目标= .NET 3.5(第二有趣的是)

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Csc.exe
/noconfig
/nowarn:1701,1702
/warn:4
/define:TRACE
/optimize+
/out:obj\Release\TestEditor.dll
/target:library

/nostdlib+ /errorreport:prompt

/reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll
/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll"
/reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll
/reference:"C:\Program Files (x86)\Unity\Editor\Data\Managed\UnityEngine.dll"

/debug:pdbonly
/filealign:512

解决方法:

最新的稳定Mono版本(2.10.9)附带的2.0 C#编译器(mcs / gmcs)支持默认功能参数.我刚刚创建了一个新的控制台项目,将目标框架更改为2.0,并成功编译了默认功能参数.

标签:mono,dll,monodevelop,c,net
来源: https://codeday.me/bug/20191031/1979739.html