4

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?

BlueBSH
  • 291
  • 3
  • 9

1 Answers1

1

When you add a resource to an existing resx-file it will be stored as base64 in der resx-file.

An "normal" embedded resource is added like your sample, but the "Update"-Attribute could be a/the problem. This attribute means, you want to change an existing embedded resource, but you do not add the resource.
You have to use the "Include"-Attribute.

But as far as I know, both is identical to the old format.
Are you sure that the error is not somewhere else?

  • 4
    I stumbled upon this, if I add a true property to the project the issue goes away.. not sure if this is a correct solution or not to this issue – BlueBSH May 28 '21 at 21:26
  • the item group example above wit the form resource actually solves the problem, if i remove it the exception comes back... but that embeddedresourceusedependentuponconvention project property also seems to correct the exception – BlueBSH May 28 '21 at 21:28
  • 1
    I don't know this Property, but that it solves your problem is strange, cause: "By default, in a new .NET project, this property is set to true." Source: https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#embeddedresourceusedependentuponconvention Do you have an other item with the same filename defined in the csproj (or a referenced props-File)? So your EmbeddedResource-Line would update this item, so it's correct. – SirPalladin May 28 '21 at 21:41
  • 1
    from what I can tell this property isn't set to true by default in my converted projects, and there was no reference to that property in any of my 96 converted projects in the solution, I had to add it manually, and after doing that it started working. There are also no other items added to the project file with the file names since it is doing the newer take all in the folder as project items behavior, and there are no duplicate resource / file names either so I don't think it's because of a duplicate file – BlueBSH May 29 '21 at 12:37