Rider - 无法构建,因为该进程无法访问该文件,因为该文件正在被另一个进程使用

问题描述 投票:0回答:2

我来这里是为了发布我遇到的错误,它突然出现,但我几个小时没有碰任何东西,我只是想重建,因为我不知道我是否已经构建了。

Fody: An unhandled exception occurred:
Exception:
The process cannot access the file 'E:\Unity Project\Curator\Curator\obj\x64\Debug\Curator.exe' because it is in use by another process.
Kind:
System.IO.IOException
StackTrace:
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   to System.IO.
FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
File Share share)
   at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters) in C:\Code\Fody\cecil\Mono.Cecil\ModuleDefinition.cs:line 1144
   at InnerWeaver.WriteModule() in C:\projects\fody\FodyIsolated\ModuleWriter.cs:line 18
   at InnerWeaver.Execute() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 114
Source:
mscorlib
TargetSite:
Void WinIOError(Int32, System.String)

但是,我在相同风格的论坛上查找过该错误,但找不到与我的错误相关的任何内容。

我已经做了什么:

  • 重新启动我的电脑。
  • 清理缓存骑士(与 VS 相同)。
  • 删除视为应用程序已在使用的项目。
  • 提到的exe不存在。
  • 查看提到的目录是否存在。 (没有剧透)。
  • 切换构建类型(64 -> 32)并从调试切换到发布。

请注意,我无法再在发行版或 32 位中启动构建应用程序。

我尝试编译其他项目以查看错误是否仍然存在,并且我逐个字符地遇到完全相同的错误。

我也尝试了 Visual Studio 2022 和 Visual Studio Code,问题仍然存在。

c# .net .net-core rider jetbrains-rider
2个回答
3
投票

好的,我发现错误了。

如果您遇到这种情况,当然,删除

"\obj\"
文件夹中的所有文件。 删除缓存(构建、系统缓存、本地历史记录、VS 日志缓存和索引、引擎缓存和 cookies。

File
->
Invalidate Caches
->
Check all options
->
Invalidate and Restart

通常这应该可以修复错误。


0
投票

虽然接受的答案没有为我解决问题,但它帮助我诊断了问题。就我而言,问题是由于通过包管理器控制台完成的

.NET Host
失败,
dotnet-ef database update
挂在文件上。当我尝试删除 @Maxime66410 在他们的答案中提到的
obj
文件夹中的文件时,我发现了这一点。一旦我通过任务管理器找到该进程并结束它,我就可以再次构建。

© www.soinside.com 2019 - 2024. All rights reserved.