.netf#resxtype-providers

Error while using type provider 'FSharp.Configuration.ResourceProvider'


I just loaded FSharp.Configuration in paket files and created a type with

open FSharp.Configuration
type ResourceProvider = ResXProvider<file="Resources/Strings.resx">

In Strings.resx are resources with e.g.:

<data name="Greeting" xml:space="preserve">
    <value>Hello</value>
</data>

Everything compiles. But when I call that resource through the provider with ResourceProvider.Greeting I get this error:

error FS3033: The type provider 'FSharp.Configuration.ConfigTypeProvider+FSharpConfigurationProvider' 
reported an error in the context of provided type: 
'FSharp.Configuration.ResXProvider,file="Resources/Strings.resx"', member 'get_Greeting'. 
Error: Method 'System.Object readValue[Object](System.String, System.Reflection.Assembly,
 System.String)' not found in type '<null>'. This method may be missing in the types 
available in the target assemblies.

Can anyone help me with that error message? I found no solution to this message.

Thanks.

Edit: it's a .NET 6 project.


Solution

  • After browsing the GitHub repository, I think the problem is that ResXProvider doesn't yet support .NET 5 (let alone .NET 6). The ResXProvider test file has a compiler directive that limits it to .NET 4.6.1, and there's an open issue about missing support for .NET Core.

    As an alternative, I suggest using Assembly.GetManifestResourceStream instead.