在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

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

调试器设置为


当前回答

删除Bin文件夹中的Debug或Release文件夹下的所有.cache文件。

其他回答

关闭进程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\。这样做之后,一切都解决了。

用款。我通过编辑MSBuild.Community.Tasks.Targets文件并更改bin路径解决了这个问题:

<MSBuildDnnBinPath Condition="'$(MSBuildDnnBinPath)' == ''">$(MSBuildProjectDirectory)\bin</MSBuildDnnBinPath>

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托管过程的目的是什么?

在你的主项目taskkill /f /fi "pid gt 0" /im "YourProcess.vshost.exe"中添加预构建事件

最快的方法是更改Build配置类型并再次返回到以前的配置。