October 24th and 25th 2006 will go down as the most annoying days that I have had (for the better part of my software development life). Anyone who has seen this CS0433 error after converting a VS2005 website to a Web Application Project will feel my pain.
Here are the following events which had occurred:
- A VS2005 website was created and a small number of pages, controls, sitemaps, etc were added.
- A decision in the department was made to use the VS2005 Web Application Project for .Net 2.0 websites.
- Our group downloaded and installed the WAP Add-In (Download Here)
- I removed all of the VSS bindings (we are still waiting to receive our full Team Foundation Server edition)
- I followed steps to Upgrade a VS2005 Web Site Project to VS2005 Web Application Project tutorial.
- Everything went smoothly except that it was kind of a pain to add the namespaces to all of the source files. Nonetheless, I was happy because I was out of the horrific WebSite method of developing web applications. The application built correctly and I added to a separate project in VSS.
Everything seemed to be going great until I fired up the debugger and ran my application.
This is the error which I would stare in the face for the next 8 hours
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: CS0433: The type 'AgencyPro.UserControl_NavTree' exists in both 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\3f88d5c8\5840425e\assembly\dl3\e396fa14\0b806043_51f8c601\AgencyPro.DLL' and 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\3f88d5c8\5840425e\App_Web_navtree.ascx.78d7338a.aftov38w.dll'
Better yet here is the actual screen so that you can have the image burned into your mind.
I did a search on Google and it turned out that tons of people had faced this similar issue. However, I was completely unable to find anything which directly gave me a fix.
Initially I thought this issue was caused for several different reasons.
- Maybe I needed to add the default namespace to all of the files in the project? - I did this and the issue continued.
- Maybe it was because I had the reserved directory App_Code in the project? - I removed this and the problem was still there.
- Maybe I needed to create an entire new project and add all of the files to that again? - I did this and the issue continued.
The obvious answer was that this error was being caused by the new ASP.NET compilation methods where a dll is generated for each of the pages (so lame in my opinion), but it was all a matter of trying to figure out how to override this behavior. After searching around in the web.config documentation, I felt stumped and due to the difficulty with generating a search phase which would turn up any real answers I was lacking documentation.
At this point I was getting a little desperate and frustrated but I knew that if I created the project from scratch and added all of the files from scratch as well, then this issue would go away. In fact, the only solutions that I had found for this issue had been describing doing just this. So, I gave up, and rebuilt everything from scratch (meaning copying and pasting all of the code into brand new files) but I still had to know what the fix was.
A buddy of mine @ work (Bruce Hoang) came over to my desk and told me to check out this article at DevX. Yes! All of my questions were answered.
Solution:
- Remove the App_Code directory from the project.
- Change the CodeFile attribute to CodeBehind on your .aspx, .ascx, .master, etc. pages.
Main Cause
- I followed all of the recommended steps in the VS Web Site to VS WAP conversion but now in hindsite I think that the issue was caused by the fact that my files were still ReadOnly from VSS. Therefore when I ran the conversion, it was not able to change the CodeFile attribute to the CodeBehind attribute on all of the pages.
Above - The Attribute that stole my time!
For an in depth article on ASP.NET 2.0 compilation and deployment issues I would recommend this as a must read.