我无法FSharpOption<>在我的C#PCL项目中引用Visual Studio 2015中的Xamarin.Android.
这是一段视频,展示了我试图解决它的步骤.
我收到的错误如下:
该类型
FSharpOption<>在未引用的程序集中定义.您必须添加对程序集的引用
FSharp.Core, Version=3.7.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
注意:
我的C#项目参考FSharp.Core.它引用了我的F#项目正在使用的相同FSharp.Core版本:
some_path\packages\FSharp.Core.4.0.0.1\lib\portable-net45+monoandroid10+monotouch10+xamarinios10\FSharp.Core.dll
Run Code Online (Sandbox Code Playgroud)
添加App配置
我放在Android客户端项目中的app.config文件与我在我用F#编写的测试项目中使用的app.config文件相同.
app.config如下:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a"
culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="4.4.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Run Code Online (Sandbox Code Playgroud)
任何人都可以向我提供有关在我的C#项目中引用FSharp.Core功能所需步骤的指导吗?
更新
我有另一个类在同一个C#项目中成功引用FSharp.Core:
static class Utility
{
public static bool IsSome(this FSharpOption<string> option) => FSharpOption<string>.get_IsSome(option);
public static bool IsNone(this FSharpOption<string> option) => FSharpOption<string>.get_IsNone(option);
}
Run Code Online (Sandbox Code Playgroud)
上面的代码似乎不会导致任何编译错误.同样,此文件与我的其他文件位于同一项目中,确实会导致错误.
导致错误的代码如下:
using Microsoft.FSharp.Core;
// . . .
if (_viewModel.FamilySummary.IsSome()) {
}
Run Code Online (Sandbox Code Playgroud)
注意: FSharp.Core
的using语句似乎被忽略.
我的viewmodel托管在Visual Studio内的一个F#项目中.