简体   繁体   English

无法将“obj\Debug\Program.exe”复制到“bin\Debug\Program.exe”。 超过重试次数 10。失败

[英]Could not copy "obj\Debug\Program.exe" to "bin\Debug\Program.exe". Exceeded retry count of 10. Failed

I'm trying to download a file from the inte.net.我正在尝试从 inte.net 下载文件。 I have an if statement and the else clause triggers the file download.我有一个 if 语句,else 子句触发文件下载。 This is my code:这是我的代码:

if (!FileDownload)
{

}
else
{
    using (WebClient wc = new WebClient())
    {
        wc.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
        wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
        wc.DownloadFileAsync(new Uri("https://www.google.com/Program.exe"),Application.StartupPath);
        MessageBox.Show("Yes");
    }

When I try to run my program I get the following errors:当我尝试运行我的程序时,出现以下错误:

Error 1:错误一:

Could not copy "obj\Debug\Program.exe" to "bin\Debug\Program.exe". Exceeded retry count of 10. Failed.

Error 2:错误二:

Unable to copy file "obj\Debug\Program.exe" to "bin\Debug\Program.exe". Could not find file 'obj\Debug\Program.exe'.

And around 10 warnings with the same message:以及大约 10 个带有相同消息的警告:

   Could not copy "obj\Debug\Program.exe" to "bin\Debug\Program.exe". Beginning retry 1 in 1000ms. Could not find file 'obj\Debug\Program.exe'. 

However, once I remove the else clause in my if statement, the program executes without any errors.但是,一旦我删除了 if 语句中的 else 子句,程序就会执行而不会出现任何错误。 The download code in the else clause is obviously causing the problem but I'm not sure why. else 子句中的下载代码显然是导致问题的原因,但我不确定为什么。 I have used the same code in the same form at a different event and it's working flawlessly.我在不同的事件中以相同的形式使用了相同的代码,并且它工作得很好。 Any help is appreciated.任何帮助表示赞赏。

I have already tried:我已经尝试过:

  • Close and reopen visual studio关闭并重新打开视觉工作室
  • Delete all the files from the bin folder then rebuild.从 bin 文件夹中删除所有文件,然后重建。
  • Checked if the file is locked with Process Explorer检查文件是否被 Process Explorer 锁定
  • Manually run VS as admin以管理员身份手动运行VS
  • Delete bin and debug folder删除bin和debug文件夹
  • Reboot computer and move project to a different folder重新启动计算机并将项目移动到不同的文件夹

Just do one thing Open Visual Studio as Administrator Rights as show in below image. 只需做一件事打开Visual Studio作为管理员权限,如下图所示。 在此输入图像描述

and problem solve do below trick to exit all process after you close your application so you dont get another problems like this. 和问题解决在关闭你的应用程序后退出所有进程的下面的技巧,所以你不会得到这样的另一个问题。

Just try this one I think you will get your solution 试试这个,我想你会得到你的解决方案

Add Application.Exit() in Main form or MDI form's Closing event like below Main窗体MDI窗体的Closing事件中添加Application.Exit() ,如下所示

Private Sub frmMain_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing Application.Exit() End Sub Private Sub frmMain_FormClosing(sender As Object,e As System.Windows.Forms.FormClosingEventArgs)处理Me.FormClosing Application.Exit()End Sub

I'm sure you're not deleting the files from correct bin folder. 我确定你没有从正确的bin文件夹中删除文件。 Open the TaskManager look for any program named Program.exe . 打开TaskManager查找名为Program.exe任何程序。 Verify where the process is running from Open file Location . Open file Location验证进程的运行Open file Location

Kill the Program.exe and try rebuilding again. 杀死Program.exe并再次尝试重建。 If it works then your bin output path is mapped to this location. 如果它工作,那么bin输出路径将映射到此位置。

Just gave a close look at the error message: Unable to copy file "obj\\Debug\\Program.exe" to "bin\\Debug\\Program.exe". 只是仔细看看错误消息:无法将文件“obj \\ Debug \\ Program.exe”复制到“bin \\ Debug \\ Program.exe”。 Could not find file 'obj\\Debug\\Program.exe' 找不到文件'obj \\ Debug \\ Program.exe'

Do you have any PostBuild step configured to copy files? 您是否配置了任何PostBuild步骤来复制文件? if yes remove that. 如果是,删除它。

Also edit your .csproj file and search for 'obj\\Debug' if there's anything that matches with it delete that and try again. 还要编辑你的.csproj文件并搜索'obj \\ Debug'如果有任何匹配它的内容删除它并重试。

More advanced troubleshooting: 更高级的故障排除

Use the process monitor and filter the process for VisualStudio and the path. 使用过程监视器并过滤VisualStudio和路径的过程。 see below screenshot 见下面的截图

在此输入图像描述

Build your project again and Investigate the profiling logs why it's trying to copy the Program.exe. 再次构建项目并调查分析日志,以便它尝试复制Program.exe。

在此输入图像描述

Add/Remove more filters to see why it's tyring to copy the Program.exe. 添加/删除更多过滤器,以查看复制Program.exe的原因。 Also look for any Errors in Result column. 还要查找“ Result列中的任何“错误”。

I solved the problem myself. 我自己解决了这个问题。 After trying lots of different solutions that had worked for other people but not for me I tried to look at the different processes running at the same time I'm trying to execute the program. 在尝试了许多不同的解决方案之后,这些解决方案已经为其他人工作但不适合我,我试着在我尝试执行程序的同时查看运行的不同进程。 The problem was Avast. 问题是Avast。 I turned off Avast Anti Virus and it instantly solved the problem. 我关闭了Avast Anti Virus,它立即解决了这个问题。 For some reason Avast didn't even show any messages every time it deleted the program. 出于某种原因,Avast每次删除程序时都没有显示任何消息。 I have an existing problem with my program - in that some AV's (2/72) detect my program as a virus. 我的程序存在问题 - 因为某些AV(2/72)将我的程序检测为病毒。 It has something to do with my code structure. 它与我的代码结构有关。 Thanks for the answers everyone - it should be useful to other people who have a similar error. 感谢大家的答案 - 对于有类似错误的其他人应该有用。

I had the same error then I realized that I had run the project therefore after closing it and rebuilding again it was solved我遇到了同样的错误,然后我意识到我已经运行了该项目,因此在关闭它并再次重建后它就解决了

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Opentap 无法将“[名称].dll”复制到“bin\\Debug\\Dependencies\\[Name].dll”。 超过 10 次重试次数。失败 - Opentap Could not copy "[name].dll" to "bin\Debug\Dependencies\[Name].dll". Exceeded retry count of 10. Failed 我可以单独使用Debug \\ program.exe吗? - Can I use the Debug\program.exe as a standalone? 将C#程序编译到Program.exe中时出错 - Error Compiling C# program into Program.exe 如果编译后program.exe名称更改,则无法加载资源 - Resource can not be loaded IF program.exe name changed after compiling 如何解决错误:无法复制...重试次数超过 10 次。失败。 - VS 2017 - How to solve Error : Could not copy ... Exceeded retry count of 10. Failed. - VS 2017 错误 MSB3027:无法将“C:\\pagefile.sys”复制到“bin\\roslyn\\pagefile.sys”。 超过 10 次重试次数。失败 - Error MSB3027: Could not copy “C:\pagefile.sys” to “bin\roslyn\pagefile.sys”. Exceeded retry count of 10. Failed WPF:program.exe不会退出“该进程无法访问该文件。 - WPF: program.exe doesn't exit “the process cannot access the file.. used by another process” 由于找不到文件“ obj \\ Debug \\ example.exe”,因此无法复制 - Could not copy the file “obj\Debug\example.exe” because it was not found “重试次数超过 10。失败。” 因为 csproj 配置错误 - “Exceeded retry count of 10. Failed.” because of csproj misconfiguration Visual Studio 构建失败:无法将 exe 文件从 obj\debug 复制到 bin\debug - Visual Studio build fails: unable to copy exe-file from obj\debug to bin\debug
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM