.NET Framework and .NET Standard
ResXLocalization runs on .NET Framework 4.8.1 as well as on modern .NET, and its engine can be referenced from .NET Standard 2.0 libraries. The public API is the same on every target: the same types, the same members, the same generated keys.
Supported frameworks
| Package | Target frameworks |
|---|---|
ResXLocalization.WPF |
net481, net8.0-windows, net10.0-windows |
ResXLocalization.Avalonia |
net8.0, net10.0 |
ResXLocalization.Core |
netstandard2.0, net481, net8.0, net10.0 |
ResXLocalization.MessageFormat |
netstandard2.0, net481, net8.0, net10.0 |
A .NET Framework application gets the net481 assemblies, not the netstandard2.0 ones, so it does not
need the .NET Standard facade assemblies in its output. A library that targets netstandard2.0 can reference
Core and MessageFormat - for example to own the .resx files and the lookups of an application that runs on
both .NET Framework and modern .NET.
ResXLocalization.WPF has no netstandard2.0 build, because WPF is not part of .NET Standard.
ResXLocalization.Avalonia has no .NET Framework build. Avalonia 12, the oldest version the package
supports, requires .NET 8, so there is no .NET Framework Avalonia application for it to serve.
Requirements
PackageReference only
Reference the packages with PackageReference. A project that uses packages.config is not supported:
NuGet ignores a package's buildTransitive folder there, so such a project gets no .resx wiring and no
generated keys - StringsKeys and the other …Keys classes do not exist, and every use of them is a build
error. The runtime assemblies would still be referenced, but the library's main feature would be missing.
An old-style project can usually be moved to PackageReference without changing anything else: in Visual
Studio, right-click packages.config and choose Migrate packages.config to PackageReference. Converting
the project to the SDK-style format is not required, though it is what the rest of this page assumes.
Visual Studio 2022 17.8 or later
The packages carry a source generator that needs Roslyn 4.8 or later, on every target framework. That is
Visual Studio 2022 17.8 or later, the .NET 8 SDK or later, or a matching MSBuild. An older compiler
does not load the generator (CS9057), and the build then fails on the missing …Keys types.
Generated keys under C# 7.3
.NET Framework projects default to C# 7.3, and the generated keys compile under it: the generated code uses a
braced namespace and explicitly typed new expressions, and no #nullable directive. Nothing has to be set
for this, and every project, whatever its language version, gets the same code. See
Generated keys.
Binding redirects
On .NET Framework, ResXLocalization.MessageFormat brings System.Memory and the packages it depends on, and
an application can end up with assembly versions that differ from the ones a library was compiled against.
.NET Framework needs binding redirects for that:
- SDK-style projects generate them automatically. Nothing to do.
- Non-SDK-style projects need
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>in the project file (and, for a library's test project,<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>), or hand-written redirects inapp.config.
A missing redirect shows up at run time as a FileLoadException naming one of those assemblies.
Native AOT and trimming
Native AOT and trimming are features of .NET 8 and later, and only there does the library support them - see Native AOT and trimming. On .NET Framework and .NET Standard nothing is trimmed, and the trimming annotations the library carries have no effect.