In a MVC2 project I moved a file from App_code to Content folder and compiled it. Then move it back again to App_Code and then changed its Build Action to \"Compile\". Now I
Try to change folder name
APP_CODE
CODE
.This fixed my issue.
Alternatively you can move to another folder all your code files.
TRY THIS ONE!
Normally, when this happen locally, i clean all the aspnet temp folder. But recently it was happing when i published my website in Azure. So "clean temp aspnet folder" was not a solution.
After searching on the internet, i founded this:
Clear Temp ASP.NET files from Azure Web Site
It works for me!
The App_Code folder isn't intended to be used with MVC Projects (WAP).
Files in the App_Code folder gets compiled automatically as part of a special dll. If the Build Action property on the file is set to Compile, the same class will also get compiled as part of the main dll and you will end up with two copies.
Setting the Build Action property to None makes sure there is only one copy of the class in the project. The compiler will not catch any errors in the App_Code folder when building but Intellisense will still validate the code but compile-time errors won't show up until it is compiled on-the-fly.
The recommended solution is to put code in a normal folder and make sure the Build Action is set to Compile.
If your are migrating ASP.NET 2.0 Website to .NET Web APP 4.5, you can have that issue too. And puting batch=false, adding a namespace etc... can not work.
The workaround is to rename the old App_Code folder (or any problematic folder) to Old_App_Code (like the automatic process do it), or any other name.
Try cleaning your solution and then try to rebuild. Visual Studio probably still has reference to the old dll after it created the new dll.
I fixed this by checking Delete all existing files prior to publish
in Visual Studio: