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 get this error and I don't know how to fix this to make my program work again:
CS0433: The type 'Helper' exists in both 'c:\Users...\AppData\Local\Temp\Temporary ASP.NET Files\root\b00d4b7d\b2553f9c\App_Code.zowyklar.dll' and 'c:\Users...\AppData\Local\Temp\Temporary ASP.NET Files\root\b00d4b7d\b2553f9c\assembly\dl3\5c6d3537\19f85663_cde9cb01\MyProject.DLL'
Cleaning and Rebuilding doesn't solve the problem.
This has been answered in a separate question and resolved the problem for me. Be sure to vote up the original person's answer.
ASP.Net error: "The type 'foo' exists in both "temp1.dll" and "temp2.dll"
Add the batch="false" attribute to the "compilation" element of the web.config file.
This problem occurs because of the way in which ASP.NET 2.0 uses the application references and the folder structure of the application to compile the application. If the batch property of the element in the web.config file for the application is set to true, ASP.NET 2.0 compiles each folder in the application into a separate assembly.
http://www.sellsbrothers.com/news/showTopic.aspx?ixTopic=1995
http://support.microsoft.com/kb/919284
Assuming you're building a Web Application, which it appears you are given the MVC2 point, you shouldn't use the App_Code folder. It was not designed to be integrated with Web Application projects.
When you Compile in Visual Studio, all the code in your application (including in App_Code) gets compiled into an assembly. When you run your application, asp.net knows about a "special" folder called App_Code and compiles the content of it into an assembly with a unique name. Thus, anytime you run the project you'll run into this problem.
The solution:
Rename your App_Code folder to something like "Code" or "Global" (and update your now broken references) & voila, problem solved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With