When you try to open a page or compile an application, the framework tries to load an older version of your application, which was cached when you run your project previously. This may cause this issue.
To solve it, do the following:
1. Close Visual Studio;
2. Clear "Temporary ASP.NET Files" directories using A tool for clearing Temporary ASP.NET files.
You can do it manually by clearing the following folders:
- C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\
- C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\
- C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\
- C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\
- C:\Users\[your_user_name]\AppData\Local\Temp\Temporary ASP.NET Files\
Restart the "World Wide Web Publishing" service (Start menu\Settings\Control Panel\Administrative tools\Services).
3. Clear the project's Bin and Obj folders and deploy new assemblies if it is necessary;
4. Rebuild your application.