As far as I understand, F# type provider is always going to be a non-portable class library (eg it will use Reflection.Emit which is not available in WinRT). To use it in my F# class library, I need to add a reference to the type provider DLL, so that library has to be non-portable to compile.
In this case I'm happy to separate into one portable assembly and one which uses the type provider. The only way I can get this to compile is by adding a reference to Fsharp.Core to my C# application project (.NET 4.5) - but at runtime there is still a conflict between the versions of FSharp.Core.
{"Could not load file or assembly 'FSharp.Core, Version=2.3.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.":"FSharp.Core, Version=2.3.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"}
Can I resolve the conflict, am I using type providers wrongly, or is it something that can't be done yet?
You need a binding redirect in your app.config file. If you create a new F# project that targets 4.5 it will have
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="2.3.5.0" newVersion="4.3.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
in the app.config. You need to add that in the app.config of the final consuming exe project (e.g. the C# one), so that e.g. if you run it on the desktop, it will resolve the portable FSharp.Core (2.3.5.0) to the desktop one (4.3.0.0).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With