Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid .resx file after renamed namespace

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...

like image 520
Martin Christiansen Avatar asked Dec 12 '22 20:12

Martin Christiansen


2 Answers

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

like image 75
Stefania Mereut Avatar answered Jan 03 '23 08:01

Stefania Mereut


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.

like image 39
sn00gan Avatar answered Jan 03 '23 06:01

sn00gan