在VS2012 c#项目的构建过程中,我一直得到这个错误

Error   41  Could not copy "obj\Debug\WeinGartner.WeinCad.exe" to
 "bin\Debug\WeinGartner.WeinCad.exe". 
 Exceeded retry count of 10. Failed.    


Error   42  Unable to copy file "obj\Debug\WeinGartner.WeinCad.exe" to
"bin\Debug\WeinGartner.WeinCad.exe". The process cannot access the file
'bin\Debug\WeinGartner.WeinCad.exe' because it is being used by another 
process.    

现在我知道该终止进程了

Weingartner.WeinCad.vhost.exe

(有时)有用,但这让我很紧张。有办法阻止这一切发生吗?

调试器设置为


当前回答

I experienced the error-messages when attempting to build the primary WinForms (XAF) project. I could only execute the application one time then needed to shutdown the VS2015 IDE and restart before a rebuild could be performed. After some digging in the project's property pages - in the "debug" property page, a check box was selected - Enable the Visual Studio Hosting Process. I unchecked and restarted the IDE, the application is now building without - "unable to copy the {project}.exe" messages.

Visual Studio托管过程的目的是什么?

其他回答

花了几个小时试图解决这个问题,然后发现我正在处理一个服务-记住停止任何服务作为解决方案的一部分!

关闭进程w3wp.exe (IIS)通常可以解决这个问题。通常,您可以通过导航到bin文件夹并尝试删除它来了解对该文件具有锁的进程。如果另一个进程正在使用它,将弹出的错误消息将包含需要被杀死的进程的名称。

使用Blazor和Fluent UI Web组件,我在发布时得到了以下错误:

https://learn.microsoft.com/en-us/fluent-ui/web-components/integrations/blazor

C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk.Razor\targets\Microsoft.NET.Sdk.Razor.StaticWebAssets.targets(615,5): Warning MSB3026: Could not copy "C:\Users\oscar.nuget\packages\microsoft.fast.components.fluentui\1.5.3\staticwebassets\icons\TextDirectionRotate270Right\en\text_direction_rotate_270_right_24_regular.svg" to "C:\Users\oscar\source\repos\MyVeryLongProjectName12345678\MyVeryLongProjectName12345678\Server\obj\Release\net6.0\PubTmp\Out\wwwroot_content\Microsoft.Fast.Components.FluentUI\icons\TextDirectionRotate270Right\en\text_direction_rotate_270_right_24_regular.svg". Beginning retry 10 in 1000ms. Could not find a part of the path 'C:\Users\oscar\source\repos\MyVeryLongProjectName12345678\MyVeryLongProjectName12345678\Server\obj\Release\net6.0\PubTmp\Out\wwwroot_content\Microsoft.Fast.Components.FluentUI\icons\TextDirectionRotate270Right\en\text_direction_rotate_270_right_24_regular.svg'. C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk.Razor\targets\Microsoft.NET.Sdk.Razor.StaticWebAssets.targets(615,5): Warning MSB3026: Could not copy "C:\Users\oscar.nuget\packages\microsoft.fast.components.fluentui\1.5.3\staticwebassets\icons\TextDirectionRotate270Right\en\text_direction_rotate_270_right_20_regular.svg" to "C:\Users\oscar\source\repos\MyVeryLongProjectName12345678\MyVeryLongProjectName12345678\Server\obj\Release\net6.0\PubTmp\Out\wwwroot_content\Microsoft.Fast.Components.FluentUI\icons\TextDirectionRotate270Right\en\text_direction_rotate_270_right_20_regular.svg". Beginning retry 10 in 1000ms. Could not find a part of the path 'C:\Users\oscar\source\repos\MyVeryLongProjectName12345678\MyVeryLongProjectName12345678\Server\obj\Release\net6.0\PubTmp\Out\wwwroot_content\Microsoft.Fast.Components.FluentUI\icons\TextDirectionRotate270Right\en\text_direction_rotate_270_right_20_regular.svg'. C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk.Razor\targets\Microsoft.NET.Sdk.Razor.StaticWebAssets.targets(615,5): Error MSB3027: Could not copy "C:\Users\oscar.nuget\packages\microsoft.fast.components.fluentui\1.5.3\staticwebassets\icons\TextDirectionHorizontalRight\ko\text_direction_horizontal_right_24_regular.svg" to "C:\Users\oscar\source\repos\MyVeryLongProjectName12345678\MyVeryLongProjectName12345678\Server\obj\Release\net6.0\PubTmp\Out\wwwroot_content\Microsoft.Fast.Components.FluentUI\icons\TextDirectionHorizontalRight\ko\text_direction_horizontal_right_24_regular.svg". Exceeded retry count of 10. Failed.

看着

C:\Users\oscar\source\repos\MyVeryLongProjectName12345678\MyVeryLongProjectName12345678\Server\obj\Release\net6.0\PubTmp\Out\wwwroot\_content\Microsoft.Fast.Components.FluentUI\icons\TextDirectionHorizontalRight\ko\text_direction_horizontal_right_24_regular.svg

长度为261个字符。

然后我尝试启用长路径并重新启动我的计算机。

https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry

这没有工作,我得到了同样的错误。然后,我将项目移动到C:\MyVeryLongProjectName12345678\,而不是C:\ users \奥斯卡\source\ rep\ MyVeryLongProjectName12345678\。这样做之后,一切都解决了。

将此添加到预构建:

(if exist "$(TargetDir)*old.exe" del "$(TargetDir)*old.exe") & (if exist "$(TargetDir)*.exe" ren "$(TargetDir)*.exe" *.old.exe)

重置IIS,停止使用您的DLL的服务(可能是控制台应用程序或windows服务托管应用程序或IIS),然后尝试。

这对我很管用。

我也遇到过同样的问题,我尝试了这里提到的很多不同的方法,但没有一个对我有效,唯一对我有效的解决方案是:

从解决方案的DEBUG文件夹中删除READ ONLY属性 将此添加到构建事件:如果存在“$(TargetPath)”。$(TargetPath).locked" $(TargetPath)。锁定" if exists "$(TargetPath)" move "$(TargetPath)"“$(定位路径).locked”