C# 如何清除用于编译的 ASP.NET 应用程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17651282/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How Do You Clear an ASP.NET app for compiling?
提问by xarzu
I have been building and rebuilding an ASP.NET program.
我一直在构建和重建一个 ASP.NET 程序。
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
错误 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:......\
'ChildEventHandler' 类型同时存在于 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files...\b90cc7a4\28d266b\assembly\dl3\c4cf1ea3\b6e4b808_ef7cce01\App_Code' 中。 '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.
我在 Visual Studio 中没有看到用于清除编译文件的“清除”选项。


回答by Chris Dixon
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.
如果您没有“Clean Solution”选项(可能是 Express 版本,或者 2010 之前的版本没有这个选项?)那么,要修复此错误,只需转到您的解决方案的 /bin 文件夹并删除所有项目,然后再次构建。
This will recompile all the DLL files.
这将重新编译所有 DLL 文件。
回答by Gayatri
This problem I faced sometimes back while compiling. Go to this folder
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Filesand 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.
我在编译时有时会遇到这个问题。转到此文件夹
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files并删除其下的所有文件和文件夹。当您构建不在 IIS 下托管的应用程序时,会在此文件夹下创建临时调试文件和文件夹。
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.
删除它们时,您可能会收到拒绝访问错误。关闭 Visual Studio 解决方案并删除此文件夹下的所有内容。它将解决编译错误。
回答by Paul
For those using Visual Studio 2015 in Windows 8 or Windows 10, the solution is to remove all temp files from the following location:
对于在 Windows 8 或 Windows 10 中使用 Visual Studio 2015 的用户,解决方案是从以下位置删除所有临时文件:
%AppData%\Local\Temp\Temporary ASP.NET Files
%AppData%\Local\Temp\Temporary ASP.NET Files
and then rebuild your Solution.
然后重建您的解决方案。
回答by yu yang Jian
In my case, the error is come from some cshtmlfiles 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 filesto show the not included files, and try to open them to find the possible files that cause the error.
在我的情况下,错误是来自一些cshtml文件,这些文件under project folder but not included in project。因此,如果您在整个解决方案中搜索错误,则无法找到。您可以使用show all files来显示未包含的文件,并尝试打开它们以查找可能导致错误的文件。

