Search code examples
c#resx

Namespace conflit while using global resource file for multiple languages


I have created two resources files with names:

  1. ManageUserResources.resx
  2. ManageUserResources.zn-CN.resx

Now respective namespaces in designer.cs are:

  1. Resources
  2. Resources.ManageUserResources

//Error: The namespace resources already contains definition for ManageUserResources

  1. Is this conflict between namespace and class(having same names)?
  2. Any solution for this problem?

Solution

  • While creating resource files for name spaces for multiple languages, always make sure you check the correct culture code. In your case the for ManageUserResources.zn-CN.resx. Considering you wanted to select China, it should have been ManageUserResources.zh-CN.resx The code for china is zh-CN and this should not be replaced.

    Coming to your problem:

    Specifically the error occurs in the Resources.Designer.cs You could just delete the file and let Visual studio regenerate it.

    I've had this problem, too, and it was because I created a new namespace, but the parent namespace contained a class with the same name.

    To find this, I used the object browser and searched for the name of the item that was already defined.

    If it won't let you do this while you still have the error, then temporarily change the name of the item it is complaining about and then find the offending item.

    Hope this helps.