问题描述
我使用了一些F#类型(的等)从C#,所以我需要引用FSharp.Core装配在我的C#项目。到目前为止,所以好。
I'm using some F# types (Matrix et al) from C# and so I need to reference the FSharp.Core assembly in my C# project. So far, so good.
但是,也有明显在mscorlib.dll(V4)定义了一些类型的它们在FSharp.Core(v2)的复制,象 System.Tuple
和 System.IObservable
。我不明白为什么这是在.NET 4 :
However, there are apparently some types defined in mscorlib.dll (v4) which are "duplicated" in FSharp.Core (v2), like System.Tuple
and System.IObservable
. I can't understand why this is in .Net 4. Matt Ellis specifically said they would be removed in his MSDN article:
一语苦难[复制]问题是F#,而此前已定义的FSharp自己的元组类型。 Core.dll但现在将使用Microsoft .NET Framework中添加4元组。
我准备过去看看这个特别的不体面重复,如果我可以只指定我想在我的C#程序使用哪一个,但是。当我尝试使用 System.Tuple
类型,例如,我得到下面的C#编译器错误:
I'm ready to look past this particular unseemly duplication if I could just specify which one I want to use in my C# program, however. When I try to use the System.Tuple
type, for example, I get the following C# compiler error:
错误2'System.Tuple'两个'C存在类型:\Program文件(x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\Profile\\ \\Client\mscorlib.dll'和'C:\Program文件(x86)\Reference Assemblies\Microsoft\FSharp\2.0\Runtime\v2.0\FSharp.Core.dll
解决这个问题的方式,很显然,是 C#编译器命令行上的开关:
The way around this, apparently, is a switch on the C# compiler command line which aliases the type:
CSC.EXE MyType.cs /reference:System.Tuple`2=mscorlib.dll /reference:FSharp.Core.dll
不过,我不能找到一个办法让Visual Studio中这个参数发送到C#编译器。
However, I can't find a way to get Visual Studio to send this parameter to the C# compiler.
任何人有一个解决的办法?
Anyone have a solution to this?
推荐答案
您需要引用4.0版的F#运行时。这个版本与版本4.0 mscorlib程序的对应和不具有冲突的类型。他们将在此目录中。
You need to reference the 4.0 version of the F# runtime. This version corresponds with the 4.0 version of mscorlib and does not have the conflicting types. They will be in this directory
C:\Program文件(x86)\Reference Assemblies\Microsoft\FSharp\2.0 \Runtime\v4.0
这篇关于包括FSharp.Core在C#项目:解决冲突的类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!