2017-05-19 46 views
1

我奋力化解,从我的C#PCL这个运行时异常引用了F#PCL:TypeLoadException:从试图与F#代码互操作的C#代码

未处理的异常:

System.TypeLoadException:无法与令牌0100001d (从typeref,类/组件Microsoft.FSharp.Core.FSharpResult`2, FSharp.Core,版本= 3.259.41.0文化=中性, 公钥= b03f5f7f11d50a3a)发生

解决类型

注意: 我确保我的C#和F#项目引用相同的FSharp.Core版本。

我记得当我在F#中的测试项目不能很好地处理我的F#项目时,必须添加一个用于版本控制的XML文件。这是相同的情况吗?

添加以下到我的应用程序配置上我Xamarin.Forms PCL:

<?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> 

但我仍然收到同样的错误。

回答

0

FSharpResult是(我假设)在FSharp 4.1中引入的Result<'TSuccess, 'TError>类型,因此您应该获得FSharp.Core版本4.4.1.0。

+1

感谢您的回复。我的所有项目都指向最新版本的FSharp.Core。不过,我仍遇到同样的问题。 –

+0

嗯......怪异......哪个是什么版本?在上面的问题中,你肯定会展示F#4.0,其中一个库引用了一个尚不存在的类型,也有说'FSharp.Core,Version = 3.259.41.0'。你有没有尝试nugetting Fsharp.Core?这可能是由于某些PCL混合造成的。有没有可能把这个放在GitHub上以便更好的调试? – s952163

+1

@ScottNimrod - 如果你的目标是F#4.1,那么'app.config'中的'newVersion =“4.4.0.0''应该是'newVersion =”4.4.1.0“':参见https:// fsharp。 github.io/2015/04/18/fsharp-core-notes.html#fsharpcore-version-numbers – rmunn