Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.Net error: "The type 'foo' exists in both "temp1.dll" and "temp2.dll"

Tags:

asp.net

When running a web application project, at seemingly random times a page may fail with a CS0433 error: type exists in multiple DLL's. The DLL's are all generated DLL's residing in the "Temporary ASP.NET Files" directory.

like image 517
Ben Fulton Avatar asked Dec 16 '08 14:12

Ben Fulton


2 Answers

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/1995

http://support.microsoft.com/kb/919284

like image 138
Ben Fulton Avatar answered Oct 06 '22 18:10

Ben Fulton


This might happen if you place .cs files in App_Code and changed their build action to compile in a Web Application Project.

Either have the build action for the .cs files in App_Code as Content or change the name of App_Code to something else. I changed the name since intellisense won't fix .cs files marked as content.

More info at http://vishaljoshi.blogspot.se/2009/07/appcode-folder-doesnt-work-with-web.html

like image 29
Lilja Avatar answered Oct 06 '22 16:10

Lilja