Law*_*ton 8 f# missingmethodexception f#-powerpack
所以我刚刚开始使用F#,我遇到了一个非常奇怪的问题,当我使用FSharp PowerPack中的某些方法时会抛出System.MissingMethodException.
对于同一模块中的所有方法都不会发生这种情况.如果我将程序集编译为Application而不是类库,也不会发生这种情况.
复制步骤:
在每个装配中创建以下测试夹具.
open NUnit.Framework
[<TestFixture>]
type Tests() = class
[<Test>]
member self.OfSeq() =
// Will always succeed
Matrix.Generic.ofSeq [[1]] |> ignore
[<Test>]
member self.OfList() =
// Will fail under certain conditions with a System.MissingMethodException
Matrix.Generic.ofList [[1]] |> ignore
end
Run Code Online (Sandbox Code Playgroud)当我这样做时,应用程序运行正常(所有测试都通过),但类库失败,出现以下异常:
System.MissingMethodException : Method not found: 'Microsoft.FSharp.Math.Matrix`1<!!0> Generic.ofList(Microsoft.FSharp.Collections.FSharpList`1<Microsoft.FSharp.Collections.FSharpList`1<!!0>>)'.
at Temp2.Tests.OfList()
Run Code Online (Sandbox Code Playgroud)
这里发生了什么?
产生问题的另一种方法是matrix.PermuteColumns.
附加信息:
如果有其他信息可以使用,请告诉我.
Ric*_*ard 12
(回答以后参考,因为这个Q是第一次搜索.)
使用Visual Studio 2013,使用Brian引用的"F#MSTest"在线项目模板,Brian的建议都没有帮助(首先,测试的目标是没有的库项目App.Config).
但是我最终发现测试项目设置为使用F#3运行时(使用FSharp.Core V4.3.0.0).将此更改为F#v3.1(FSharp.Core V4.3.1.0)修复了此问题.
我想知道这是否与绑定重定向有关。您可能需要将应用程序项目中的app.config复制到库项目中。
这听起来与我目前正在为 F# 团队博客(可能会在接下来的几周内出现)撰写的关于 MSTest 而不是 NUnit 的已知问题类似。我会尝试将 app.config 复制到库项目中,如果这不起作用,则在此处使用在线模板进行单元测试:
http://visualstudiogallery.msdn.microsoft.com/51ebe64a-899b-4959-8c24-b0148ed6b264
另外,从 VS 的菜单中选择“TEST\Test Settings\Select Test Settings File”,并将其指向单元测试项目模板中包含的“MSTest.runsettings”文件。我希望这两项调整之一能够在 MSTest 案例中修复它。