Hi, everyone!
Just have come across another gotcha in SharePoint (though it appears also in pure ASP.NET) – related to file naming of resources inside “App_GlobalResource” folder.
I have a project which run-time resources are collected in (let’s say) “Parent.Child.resx” file. This file is deployed to “App_GlobalResources” folder of Web Application. Recently I have added rather independent part to the solution. The textual resources of this part are externalized into “Parent.Child.Subchild.resx” file. This RESX file is also deployed to “App_GlobalResources”folder.
Once I deployed component’s resource file, SharePoint stopped working and following exception was thrown:
The first marked text was ‘Resources.Parent’ and the second (grey-filled one) was “Child” – so the full text says:
“Compiler Error Message: CS0101: The namespace ‘Resources.Parent’ already contains a definition for ‘Child’”.
I tested the problem on MOSS 2007, SharePoint 2010 and Web Site created in pure ASP.NET 4.0 – the problem appeared everywhere when I uploaded “Parent.Child.resx” together with”Parent.Child.Subchild.resx” files into “App_GlobalResources” folder.
The textual description was rather cryptic, but Visual Studio helped a lot – it showed source C# files generated from RESX files.
So, the first resource file (“Parent.Child.resx”) compiles into following code:
And the second file (“Parent.Child.Subchild.resx”) compiles into following code:
So now everything became clear – in “Resource.Parent” namespace, there are:
- “Child” class, created from Parent.Child.resx file
- “Child” sub-namespace (which is the first part of “Resources.Parent.Child” namespace), created from Parent.Child.Subchild.resx file.
The compiler is not happy about it and throws an exception.
To summarize – don’t create resource files which names are just the prefix of the names of other resource files.
Hope, it helps.



Pingback: Resource probing during provisioning | Vladimir Timashkov's blog