Non-string resources require the System.Resources.Extensions assembly at runtime, but it was not found in this project's references.

See original GitHub issue

This issue has been reported before, I believe here : https://github.com/dotnet/msbuild/issues/2221 However unlike presented in this thread, it still appears past versions 16.3+ of MSBuild. I’m personally running Microsoft (R) Build Engine version 16.7.0+7fb82e5b2 for .NET

Issue Description

My windows form app can be built successfully using Visual Studio 2019, but:

  • Cannot be built with dotnet msbuild from command line
  • Cannot be built with dotnet publish from command line
  • Cannot be built with “C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe” from command line.

Steps to Reproduce

Here are the arguments I used for all three of them: -target:Publish /p:Configuration=Release /p:GenerateResourceUsePreserializedResources=True /p:OutDir="../Build"

Expected Behavior

The app builds successfully to the target folder.

Actual Behavior

All three of them output some version of the following text:

error MSB3822: Non-string resources require the System.Resources.Extensions assembly at runtime, but it was not found in this project's references. [my.csproj]

However, none of my .resx in my windows form project have any image. Only one contains non-string content, of the following nature: image The other .resx i have seems to be doing fine without any non-string resource, but not this one - deleting these elements lead to malfunction.

Moreover, if I do try to embed the “System.Resources.Extensions” that is being mentioned here, my app does build, but said window cannot be opened. <PackageReference Include="System.Resources.Extensions" Version="4.7.1" />

image

Analysis

Tried every version of System.Resources.Extensions from the top, the application seems to work correctly with <PackageReference Include="System.Resources.Extensions" Version="4.6.0" /> for reasons unknown to me. This is still not a good solution. I feel like I shouldn’t have to include this undesired library.

Versions & Configurations

Microsoft (R) Build Engine version 16.7.0+7fb82e5b2 for .NET Windows 10 running Microsoft Visual Studio 2019

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:23 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
DaveCousineaucommented, Apr 23, 2021

I must have found myself here a dozen times or more by now.

I think there is a bug when building using dotnet where this error is generated even when building a .NET Framework project.

My command is:

dotnet publish
-o <location>
-f net40
-r win-x86
-c Release
--self-contained
-v m

and I have conditional ItemGroup and PropertyGroup tags that have the necessary tags:

<GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources>

and

<PackageReference Include="System.Resources.Extensions" Version="4.7.0" />

when building for .netcoreapp3.1

but I get the error even when building for .NET 4, where these shouldn’t be required afaik (and in fact, can’t be used I think).

0reactions
DataJugglercommented, Jun 26, 2023

I added the extension System.Resources and it fixed it, it is just strange to me that it started after an update.

Read more comments on GitHub >

github_iconTop Results From Across the Web

error MSB3823: Non-string resources require the property ...
Hello everyone I got an error and I`m trying to solve it I found some similar source but could not solve my problem....
Read more >
MSB3822 - MSBuild
Non-string resources require the System.Resources.Extensions assembly at runtime, but it was not found in this project's references.
Read more >
Project Complaining about Non-String Resources ...
... Non-string resources require the System.Resources.Extensions assembly at runtime, but it was not found in this project's references.
Read more >
Debugging in Visual Studio Mac 2022(17.5 (build 1802))
... Non-string resources require the System.Resources.Extensions assembly at runtime, but it was not found in this project's references.
Read more >
Developers - Non-string resources require the System. ...
Non-string resources require the System.Resources.Extensions assembly at runtime, but it was not found in this project's references.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found