xarzu
xarzu

Reputation: 9489

How Do You Clear an ASP.NET app for compiling?

I have been building and rebuilding an ASP.NET program.

I made the horrible mistake, I think, of recently copying the published content back to the folder I was developing.

So now I have an unusual error when I build the code. It says That there is a duplicate definition in one file in a temporary directory with anohter file in a temporary directory.

Error 3

The type 'ChildEventHandler' exists in both 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files...\b90cc7a4\28d266b\assembly\dl3\c4cf1ea3\b6e4b808_ef7cce01\App_Code.DLL' and 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files...\b90cc7a4\28d266b\App_Code.asx5jp5d.dll' C:\inetpub\wwwroot...\Resources\usercontrols....ascx.cs 11 18 C:......\

I removed project and file names, of course, but this is basically what the error says.

Since the error is with temporary files, what should I do?

I do not see a "clear" option in visual studio to clear out the files of a compile.

enter image description here

Upvotes: 21

Views: 50024

Answers (4)

yu yang Jian
yu yang Jian

Reputation: 7171

In my case, the error is come from some cshtml files that are under project folder but not included in project. So if you search the error in entire solution, it couldn't be found. You can use show all files to show the not included files, and try to open them to find the possible files that cause the error.

Upvotes: 3

Gayatri
Gayatri

Reputation: 554

This problem I faced sometimes back while compiling. Go to this folder c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files and delete all the files and folder under it. When you build an application which is not hosted under IIS, temporary debug files and folder get created under this folder.

It may happen that you get an access denied error while deleting them. Close your Visual Studio solution and delete everything under this folder. It will resolve the compilation error.

Upvotes: 36

Paul
Paul

Reputation: 291

For those using Visual Studio 2015 in Windows 8 or Windows 10, the solution is to remove all temp files from the following location:

%AppData%\Local\Temp\Temporary ASP.NET Files

and then rebuild your Solution.

Upvotes: 9

Chris Dixon
Chris Dixon

Reputation: 9167

If you haven't got the option of "Clean Solution" (maybe Express verions, or pre-2010 don't have this?) then, to fix this error, simply go to the /bin folder of your solution and delete all items, then Build again.

This will recompile all the DLL files.

Upvotes: 2

Related Questions