Friday, August 16, 2013

How to solve CS0433 compile error?

Issue: 
I got the CS0433 compile error when I tried to run my web application project, error occurred due to the user control I have.

The error message:
Compiler Error Message: CS0433: The type 'usercontrolname' exists in both 'c:\Users\username\AppData\Local\Temp\Temporary ASP.NET Files\root\f331a27e\ffbf5479\App_Web_udkg0wsp.dll' and 'c:\Users\username\AppData\Local\Temp\Temporary ASP.NET Files\root\f331a27e\ffbf5479\App_Web_hqhnzr3p.dll'

I encountered this error before, and my solution was to delete the files in temp folder manually. I was thinking if there's another better solution for this. Finally, I've found the solution.

Solution:
Just set the batch="false" attribute on the compilation section in web.config.



   <system.web>
       <compilation debug="false" batch="false"></compilation>
   </system.web>

</configuration>
This tells ASP.NET to dynamically compile individual .aspx/.ascx files into separate assemblies. This avoids the circular reference issue that triggers the exception.

I got this solution from here.