我在使用F#中的RBush时遇到困难。该库要求我定义一个实现以下接口的类。
public interface ISpatialData
{
ref readonly Envelope Envelope { get; }
}
下面是可以正常编译的控制台应用程序的代码,其中Point
类实现了ISpatialData
接口。
open RBush
type Point(minX, minY, maxX, maxY) =
let mutable envelope = Envelope(minX, minY, maxX, maxY)
interface ISpatialData with
member __.Envelope = &envelope
[<EntryPoint>]
let main _ =
let tree = RBush<Point>()
0
但是,运行该应用程序时会抛出:System.MissingMethodException: 'Method not found: 'RBush.Envelope ByRef RBush.ISpatialData.get_Envelope()'.'
如果将Point
类定义发送到F#Interactive,则会出现以下错误:error FS0193: internal error: Signature of the body and declaration in a method implementation do not match. Type: 'Point'. Assembly: 'FSI-ASSEMBLY, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
有什么想法我在做什么错吗?
答案 0 :(得分:1)
这通常表明您使用的FSharp.Core与库使用的FSharp.Core不同。将app.config修改为具有以下内容:
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=_Your .Net Version_" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-_Your FSharp.Core Version_" newVersion="_Your FSharp.Core Version_" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>