加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

在C#项目中包含FSharp.Core:解析类型冲突

发布时间:2020-12-15 06:47:05 所属栏目:百科 来源:网络整理
导读:我正在使用C#中的一些F#类型( Matrix等),所以我需要在C#项目中引用FSharp.Core程序集.到现在为止还挺好. 但是,在FSharp.Core(v2)中mscorlib.dll(v4)中定义的某些类型被显示为“重复”,如System.Tuple和System.IObservable.我不明白为什么这是在.Net 4. Matt
我正在使用C#中的一些F#类型( Matrix等),所以我需要在C#项目中引用FSharp.Core程序集.到现在为止还挺好.

但是,在FSharp.Core(v2)中mscorlib.dll(v4)中定义的某些类型被显示为“重复”,如System.Tuple和System.IObservable.我不明白为什么这是在.Net 4. Matt Ellis specifically said they would be removed in his MSDN article:

One language suffering that [duplication] problem was F#,which previously had defined its own tuple type in FSharp.Core.dll but will now use the tuple added in Microsoft .NET Framework 4.

但是,如果我可以指定我想在C#程序中使用哪一个,我已经准备好看看这个特别的非常重复的重复.当我尝试使用System.Tuple类型,例如,我得到以下C#编译器错误:

Error 2 The type ‘System.Tuple’ exists in both ‘c:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.0ProfileClientmscorlib.dll’ and ‘c:Program Files (x86)Reference AssembliesMicrosoftFSharp2.0Runtimev2.0FSharp.Core.dll’

这显然是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#编译器.

有人有解决这个问题吗?

解决方法

您需要参考4.0版本的F#运行时.此版本对应于4.0版本的mscorlib,并且没有冲突类型.他们将在这个目录

C:Program Files (x86)Reference AssembliesMicrosoftFSharp2.0Runtimev4.0

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读