【问题标题】:Exception raised copying git repository folder复制 git 存储库文件夹时引发异常
【发布时间】:2017-06-26 14:36:44
【问题描述】:

有时会发生,当我的应用程序逐个文件复制git存储库文件夹时,当其他线程想要对存储库执行某些操作时,我会遇到这种异常,例如知道Head值.

异常是System.AccessViolationException,堆栈跟踪如下:

in LibGit2Sharp.Core.NativeMethods.git_reference_lookup(git_reference*& reference, git_repository* repo, String name)
in LibGit2Sharp.Core.Proxy.git_reference_lookup(RepositoryHandle repo, String name, Boolean shouldThrowIfNotFound) in c:\projects\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:riga 1932
in LibGit2Sharp.ReferenceCollection.Resolve[T](String name) in c:\projects\libgit2sharp\LibGit2Sharp\ReferenceCollection.cs:riga 441
in LibGit2Sharp.Repository.get_Head() in c:\projects\libgit2sharp\LibGit2Sharp\Repository.cs:riga 268
in GitManager.get_CurrentBranch() in C:\Repository\MyProject\GitRepositoryManagement\GitManager.cs:riga 80

我不知道为什么会发生这种情况..任何帮助都非常感谢!!!谢谢。

【问题讨论】:

  • 权限问题。就是那个文件吗?
  • @Will 您还需要哪些其他异常详细信息?
  • @SCramphorn 我不认为这是权限问题。如果我知道另一个线程没有做任何事情时复制整个文件夹,那么一切正常。
  • 您使用的是什么版本的 LibGit2Sharp?能否请您升级到最新版本(v0.24),看看是否仍然存在?
  • @EdwardThomson 安装的 LibGit2Sharp 版本已经是 0.24.0

标签: c# git libgit2 libgit2sharp


【解决方案1】:

这个错误意味着另一个进程正在锁定文件或目录。它可能发生在 Windows 中的任何文件系统操作中,例如,我在列出目录内容时已经看到它。既然您提到您正在使用多个线程,您可能应该明确保护存储库访问,以便一次只有一个线程访问它。如果另一个进程不是您的,您可以使用procmon 实用程序查找可能的冲突进程。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-01-24
  • 2016-03-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多