Monday, August 12, 2013

The namespace 'global namespace' already contains a definition for 'xxxxx'

While troubleshooting a handler in ASP.NET suddenly, I encountered with following error. I started looking around and reverted the changes however error didn't go and then I found the reason for that :)

Server Error in '/' Application.
--------------------------------------------------------------------------------

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0101: The namespace 'global namespace' already contains a definition for 'xxxx'




I had renamed and kept the versions of the same .cs file for the handler in the same directory. You should also check whether you have a copy of the file with different name but using the same class thus having duplicate file. I took the files out of the directory and kept them somewhere else as backup, hence solved the problem. You can also save your precious time either by deleting the file or excluding it from the project.