在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
(有时)有用,但这让我很紧张。有办法阻止这一切发生吗?
调试器设置为
关闭进程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\。这样做之后,一切都解决了。
这是因为你已经关闭了你的应用程序,但它仍然在后台运行。
临时解决方案:
进入任务管理器(Ctrl + Shift + Esc)。
进入进程选项卡,找到“YourProjectName.exe”。
如果找不到自己的进程,请勾选“显示来自所有用户的进程”。
结束处理
永久解决方案:必须通过编码关闭应用程序。这是代码…
System.Windows.Forms.Application.Exit();
您必须以所有形式将此代码放入表单的关闭事件中。例子:
private void frm_menu_FormClosing(object sender, FormClosingEventArgs e)
{
System.Windows.Forms.Application.Exit();
}