Manifest resource names changed for .resources files

Juergen Bayer notified us of an issue introduced in MSBuild in .NET 3.5 "Orcas". The problem is if you have any items of type EmbeddedResource in your project file that are actually .resources format, rather than the usual .resx. In other words, for some reason you have already converted them from human-readable form. We believe the impact should not be widespread since usually projects use .resx files. Plus, "Orcas" is essentially locked down at this point, so it's too late to fix it for this release.

When we embed a resource in an assembly, we pick a name for the stream. This name is fairly unimportant, as long as it's distinct and consistent. Its only purpose is to specify the stream your resource manager should read. In VS2003, VS2005, through .NET 2.0 SP1, the stream name for .resources itself ended with the .resources extension. In VS2008/.NET 3.5, we inadvertently broke this: it no longer has .resources on the end. The effect will be at runtime your resources will not load properly. The workaround (apart from changing to use .resx instead which we will create .resources from for you) is to add a Logical Name metadata to the affected resources to specify the correct name, something like this:

    <EmbeddedResource Include="Resources\Images.resources" >

Of course, the names we pick for streams originating in .resx files did not get changed. 


Comments (4)

  1. Danie says:

    We also have this issue, after upgrading from vs2005 to vs2008 SP1.

    We have to many .resources files, so changin them to .resx files wil not be an option!

    We have upgraded all our solution files already.

    Is there a fix for this bug yet? we are very desparate.

  2. Harry says:

    Even .resx files have a problem with the resource name when building using MSBuild, see…/missingmanifestresourceexception-when-running-tests-after-building-with-msbuild

  3. Larry says:

    If you're still monitoring the post, can you explain (or point me to a link) that explains how MSFT officially converts the name of a ".resx" file into the ".resources" file name it embeds in the assembly (when compiling from VS itself). There are different criteria depending on whether the ".resx" file is a code-behind file for a Windows form, a regular (non-form-based) ".resx" file (usually strongly-named so it has its own ".Designer" file, but not necessarily), the type of project it originates from (C#, VB or C++ usually), etc. The rules can be deduced by inspecting how VS does it, but this is brittle and dependent on the project type, making it difficult to do it generically. I have a commercial add-in that needs to deal with this, so if there's an interface or some official way to do it, it would be greatly appreciated (I'm looking for the complete base name that ends up in the assembly). Thanks.

  4. Larry says:

    Just a quick follow-up to clarify what I need (see my previous post), that I'm looking for a way to do this in code. My add-in will parse the solution in Visual Studio itself, and for each ".resx" file found, needs to determine the name of the ".resources" file that will be embedded when the project containing that ".resx" file is compiled (the add-in is already written, so I only need this piece of the puzzle). Thanks.

Skip to main content