I am in a slow process of moving to .NET5 but one of the steps before that was converting all our WinForms projects to NET-SDK Project format.
This conversion has been completed, everything appears to work ok but there are some problems that I am having issues with.
Some forms that use resources will throw an exception now that states
System.Resources.MissingManifestResourceException: 'Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Demo.FormTest.resources" was correctly embedded or linked into assembly "Demo" at compile time, or that all the satellite assemblies required are loadable and fully signed.'
I have gotten around a few of these by adding the resource item to the csproj file manually, so I would have to add something like
<ItemGroup>
<EmbeddedResource Update="Demo.FormTest.resx" />
</ItemGroup
which solves the issue for that one form, but with hundreds of forms this is going to be a huge pain... is there a better way to handle all these form resource files in a NET-SDK format project?
This exception can come up for several reasons including the case of updating the project format to SDK-style; as noted in another question's answer:
To be clear, this has to be added to a
<PropertyGroup>
.That other question we a different circumstance entirely but still pointed me to this solution.
Reference: https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#embeddedresourceusedependentuponconvention says:
But for a .NET Framework project apparently this option defaults to
false
.This was a breaking change made for .NET Core 3 (see https://learn.microsoft.com/en-us/dotnet/core/compatibility/msbuild#resource-manifest-file-name-change ) but seems to affect .NET Framework projects using the SDK project file format.
Hence the combination of these factors causes the issue and setting the property in the project file explicitly avoids it.
hence the issue.