Portable libraries with type providers

As far as I understand, a provider like F # will always be a non-portable class library (for example, 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 the library is not portable for compilation.

In this case, I am pleased to split into one portable assembly and one that uses a type provider. The only way I can build this is to add a link to Fsharp.Core in my C # application project (.NET 4.5), but there is still a conflict between versions of FSharp.Core at runtime.

{"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 incorrectly, or is this something that still cannot be done?

+8
f # portable-class-library type-providers
source share
1 answer

You need binding redirects in the 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 app.config. You need to add that to the app.config of the final exe exe project (for example, C # one), so for example, if you run it on the desktop, it will decide to transfer FSharp.Core (2.3.5.0) to the desktop (4.3 .0.0).

+8
source share

All Articles