【问题标题】:System.MissingMethodException : Method not found: 'FSharp.Data.HttpResponseSystem.MissingMethodException:找不到方法:'FSharp.Data.HttpResponse
【发布时间】:2016-09-09 13:40:35
【问题描述】:

我使用 Tickspec 在 F# 中为我的应用程序编写了 AT。我正在使用FSharp.Data.Http.Request,但出现以下错误:

System.MissingMethodException : Method not found: 'FSharp.Data.HttpResponse     
FSharp.Data.Http.Request(System.String,  
Microsoft.FSharp.Core.FSharpOption`1<Microsoft.FSharp.Collections.FSharpList`1
<System.Tuple`2<System.String,System.String>>>,  
Microsoft.FSharp.Core.FSharpOption`1<System.Collections.Generic.IEnumerable`1
<System.Tuple`2<System.String,System.String>>>,   
Microsoft.FSharp.Core.FSharpOption`1<System.String>,   
Microsoft.FSharp.Core.FSharpOption`1<FSharp.Data.HttpRequestBody>,    
Microsoft.FSharp.Core.FSharpOption`1<System.Collections.Generic.IEnumerable`
1<System.Tuple`2<System.String,System.String>>>,
Microsoft.FSharp.Core.FSharpOption`1<System.Net.CookieContainer>, 
Microsoft.FSharp.Core.FSharpOption`1<Boolean>, 
Microsoft.FSharp.Core.FSharpOption`1<System.String>, 
Microsoft.FSharp.Core.FSharpOption`1<Microsoft.FSharp.Core.FSharpFunc`2
<System.Net.HttpWebRequest,System.Net.HttpWebRequest>>)'.
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] 
arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, 
Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags 
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at <StartupCode$TickSpec>.$TickSpec.createAction@212-1.Invoke()

FSharp.Data 版本为 2.1.1.0。

fsproj:

ToolsVersion is 14.0

TargetFrameworkVersion is v4.6.1

F# is 4.0.

我有另一组 AT 用于不同的应用程序,我使用相同的 FSharp.Data.dll 和相同的 Http.Request 方法,他们使用 F# 4.0,我没有遇到任何问题。

我认为 dll 没有任何问题,因为我在示例应用程序中使用了它,并且能够使用该 Http.Request 方法。我创建了一个全新的解决方案,因为我想也许我使用的是旧版本的 FSharp.Core,但 FSharp.Data 仍然存在同样的问题。

我找到的唯一解决方案是针对该特定项目恢复为 F#3.0。我不想使用F#3.0,因为我们已经将所有其他应用程序转移到F#4.0

知道如何解决这个问题吗?

【问题讨论】:

    标签: f# f#-data missingmethodexception f#-4.0


    【解决方案1】:

    将 app.config 或以下内容添加到任何现有的。如果你有多个项目。即测试和应用程序,您需要将其添加到两者中。

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
      </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-4.4.0.0" newVersion="4.4.0.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    </configuration>
    

    【讨论】:

      【解决方案2】:

      听起来您好像以某种方式绑定到 FSI 中的 F#3.x。您能否在您的脚本中看到(如果您通过脚本执行此操作)正在引用哪个版本的 FSharp.Core?

      如果我没记错的话,TickSpec 是针对 F3.x 编译的,所以这可能是绑定重定向问题或类似问题。

      【讨论】:

      • 没有提到FSharp.Core。我添加了它,MissingMethodException 消失了。 FSharp.Core 版本是 4.3.0.0 - 这对 F#4.0 是否正确?据此:fsharp.github.io/2015/04/18/… 我应该为F#4.0 引用FSharp.Core 4.4.0.1,尽管当我这样做时,MethodMissingException 重新出现......
      • 添加引用时,是否在配置文件中添加绑定重定向?
      • 你可能需要这样做 - 请参阅下面的答案 - 这可能会奏效。
      猜你喜欢
      • 2011-04-01
      • 2011-12-24
      • 1970-01-01
      • 1970-01-01
      • 2022-10-25
      • 2020-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多