4
votes

Consider the following situation:

  • In my Windows Forms appliation I have a form.
  • That form has a .resx file.
  • The form makes use of a class ("OtherClass") from another assembly ("Other.dll").
  • "Other.dll" is built in the same VisualStudio 2010 solution as the main application (just a separate project in the same solution).
  • In the main project (the Windows Forms application) I have properly added a reference to the "Other.dll" project.

Everything works well (as expected).

Now I need to change the namespace of the type contained in "Other.dll" from "Old.Namespace" to "New.Namespace":

  1. In VS2010, I bring up the Properties window of the "Other.dll" project
  2. I change the namespace in the "Default namespace" text box from "Old.Namespace" to "New.Namespace"
  3. I change namespaces in related .cs files accordingly
  4. I rebuild the modified "Other.dll" project. No errors. The modified "Other.dll" is produced OK.

Now comes the problem:

When I after this rebuild the whole solution, the compiler stops and reports that the .resx file of the form is invalid:


"Invalid Resx file. Could not load type Old.Namespace.OtherType, Other, Version 1.0.0.0, Culture=neutral, PublicKeyToken=null which is used in the .RESX file. Ensure that the necessary references have been added to your project. Line 1521, position 5"


Clearly, the .resx file still references the type with the old namespace from somewhere. That "somewhere" appers to be from inside the binary section of the .resx file!

Question: How can I make the .resx understand that it must now reference the new type (with the changed namespace)?

Please help, I really don't know how to proceed here...

4
Have you tried the "run custom tool option"(right click) on your resx?lnu
Did you try to remove the reference to Other.dll and re-add that? Maybe the "copy local=True" may cause the problem..Tobia Zambon
No. But when I right click the .resx file in Solution Explorer I don't see any "run custom tool" in the pop-up menu??? Could you be a bit more specific?Martin Christiansen
Sorry my comment crossed another one. Yes, I tried to remove the reference and add it back. Same problem.Martin Christiansen

4 Answers

10
votes

I've had the same problem and the solution was to remove the data sections from the resx file

2
votes

I too had the same problem, and after trying several other options I followed Stefania Mereut's advice and deleted the data sections from the resx file. When I re-added the resources, it apparently rewrote the data sections correctly.

1
votes

I had this problem when I was updating a reference to a new version of a dll. In my case, the references had the option "specific version" = true. In that case, it is not possible to deserialize an old version of a class inside the res file because it contains the version of the old class on it. I changed the option on my refereces "specific version" from "true" to "false" and everything worked again.

0
votes

You need to open the resx file manually and change the type name of this binary resource to the new correct type name. I'm guessing this is a non-standard (i.e. not a string or image) resource that's been added manually to the resx file directly.

I believe these can only be viewed in the 'Other' section of the ResX editor - they can't be added through it.