如何在VS2013中运行FParsec

Pet*_*ner 3 f# parsing exception fparsec visual-studio-2013

如何在VS2013专业版中运行FParsec?

我尝试使用以下nuget包:

我试图自己编译https://bitbucket.org/fparsec/main的源代码并使用生成的dll:FParsec.dllFParsecCS.dll.

但无论哪种方式,我总是得到运行教程代码的以下异常:

System.MissingMethodException
Method not found: 
  Microsoft.FSharp.Core.FSharpFunc`2<FParsec.CharStream`1<!!0>,FParsec.Reply`1<Double>> FParsec.CharParsers.pfloat()"
Run Code Online (Sandbox Code Playgroud)

任何人都可以提供逐步解决方案,让谁在VS2013上运行FParsec?

这是我尝试运行的代码:

open FParsec

[<EntryPoint>]
let main args =
  let str s = pstring s // This line works
  let floatBetweenBrackets = str "[" >>. pfloat .>> str "]" // This line breaks
  Console.ReadKey() |> ignore
  0
Run Code Online (Sandbox Code Playgroud)

Pav*_*nov 6

尝试使用以下内容将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-4.3.1.0" newVersion="4.3.1.0" />
      </dependentAssembly>
  </runtime>
</configuration>
Run Code Online (Sandbox Code Playgroud)

检查您的FSharp.Core版本,并在必要时修补此代码段.

  • 谢谢.那很有效!提示具有相同问题的所有用户:使用以下命令可以使用dll的publicKeyToken:`sn.exe -T"PathToDLL"`sn.exe-Tool位于:`C:\ Program Files(x86)\ Microsoft SDK\Windows\v8.1A\bin\NETFX 4.5.1工具`.可能你必须编辑这条路径. (2认同)