Ok I have a issue with my resx files for some reason I have this error
The namespace 'Resources' already contains a definition for 'SiteResources'
all files are within App_GlobalResources but I keep getting this error
any pointers
There is the likelihood even if you have them hidden in Visual Studio that it’s trying to read a file which is similarly named,
If within GlobalResources
you have more than 1 file try renaming the extension like this
From:
SiteResources-fr-FR.resx
To:
SiteResources-fr-Fr.old.resx(this might still be read)
try changing the extension of the latter so that its complete not a resx file like:
SiteResources-fr-Fr.old
this will 100% not be a resx file now and should stop asp.net confusing the file you wish to use.
Hope this will solve your problems.
I ran into that problem when I added a new custom culture on my App_GlobalResources folder but forgot to register it. So I had to remove the file, add the following function in global.asax
, browse a random page of my web site so the code gets to run, and finally copy the file back into its folder.
public static void CreateCulture(string name, string cultureInfo, string regionInfo)
{
try {
CultureAndRegionInfoBuilder.Unregister(name);
} catch { }
var cib = new CultureAndRegionInfoBuilder(name, CultureAndRegionModifiers.None);
cib.LoadDataFromCultureInfo(new CultureInfo(cultureInfo)); // Populate the new CultureAndRegionInfoBuilder object with culture information.
cib.LoadDataFromRegionInfo(new RegionInfo(regionInfo)); // Populate the new CultureAndRegionInfoBuilder object with region information.
cib.Register();
}
In Application_Start
:
CreateCulture("en-gb-custom", "en-gb", "gb")
Bonus: don't forget to add full permissions to user IIS_IUSRS on the following folders or the custom language will fail its registration:
C:\Windows\Globalization
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Nls\CustomLocale
This may be a bit of an edge case, but we've run across this in our development environment from time to time. We had to setup a custom culture in Windows to support en-HK. Windows 8.1 now supports this culture natively as does Windows 2012 R2, but older machines need to have the culture created. Any machine that does not have this culture setup will get this error reported. The solution is to create the culture on the machine (We have a console app created for this purpose) and everything starts working again.
I reported this answer also on How to fix "namespace x already contains a definition for x" error? Happened after converting to VS2010
I had a some problem.You should write the resources file exactly like that en-US or any country you can check from this https://msdn.microsoft.com/en-us/library/ee825488(v=cs.20).aspx I mean you cannot change the string type like this en-Us or US-en because it is special strign. I hope that is helpfull for everyone
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With