views:

220

answers:

1

I created a new VS solution which needs to contain a modified subset of files from another solution. Both solutions have a default namespace of "Microsoft.Windows.Controls". The assembly from the old solution is named "WPFToolkit", and the new assembly name is "DatePicker". One of the files I copied over to the new solution is an embedded resource named "ExceptionStringTable.txt". The contents look like the following, although I'm not sure what format it is:

; DataGrid Selection Commands
DataGrid_SelectAllCommandText=Select All
DataGrid_SelectAllKey=Ctrl+A
DataGrid_SelectAllKeyDisplayString=Ctrl+A

I set the file's "Build Action" to "Embedded Resource" like in the original solution. At runtime, it's loaded like this:

private static ResourceManager _resourceManager =
    new ResourceManager("ExceptionStringTable", typeof(SR).Assembly);

Upon executing the code

_resourceManager.GetString(id.String)
I am receiving this runtime exception:

System.Resources.MissingManifestResourceException occurred Message="Could not find any resources appropriate for the specified culture or the neutral culture. Make sure \"ExceptionStringTable.resources\" was correctly embedded or linked into assembly \"DatePicker\" at compile time, or that all the satellite assemblies required are loadable and fully signed."

Programmatically listing the assembly's resource names, I get this:

  DatePicker.g.resources
  Microsoft.Windows.Controls.Resources.ExceptionStringTable.txt
  Microsoft.Windows.Controls.Properties.Resources.resources

What do I have to do so that ExceptionStringTable.txt gets converted into its .resources equivalent then embedded into my assembly such that the uri "ExceptionStringTable" locates it?

A: 

You need to convert the txt-file to a .resource file:

resgen.exe ExceptionStringTable.txt

This will output a ExceptionStringTable.resources file. This file then needs to be added as an embedded resource

You probably want to check the old project-file to see if there is a postbuild task or something that does this automatically.

UPDATE:

The easiest way for you is probably to convert the .txt file to a .resx file:

resgen.exe ExceptionStringTable.txt ExceptionStringTable.resx

And then add this file as an embedded resourse. Afterwards you can delete the old .txt file.

johannesg