简体   繁体   English

DLL锁定-Visual Studio 2010 C ++

[英]DLL locked - Visual Studio 2010 C++

I'm currently logged onto a machine and my current problem involves a custom build step that has trouble copying a .dll to the Bin directory because Windows says it cannot access the file because it's currently being used by another process. 我目前已登录到计算机,当前的问题涉及一个自定义生成步骤,该步骤无法将.dll复制到Bin目录,因为Windows表示它无法访问该文件,因为该文件当前正在被另一个进程使用。

I'm able to reproduce this on several other projects. 我可以在其他几个项目上重现这一点。 The sequence of events is that I build a release successfully, do some test, checkout another SHA when doing a git bisect, and attempt to build a release from that SHA without doing a git clean -xfd (intentionally, because I'm trying to cache as much reusable data as possible). 事件的顺序是,我成功构建了发行版,进行了一些测试,在执行git bisect时签出了另一个SHA,并尝试从该SHA构建了一个发行版, 而没有进行git clean -xfd(这是故意的,因为我正在尝试缓存尽可能多的可重用数据)。 The weird thing is that I tried to use Process Explorer (procexp) and tasklist /m <locked_dll.dll> to search for whatever is holding onto this dll, and am unable to find anything holding onto the dll. 奇怪的是,我尝试使用Process Explorer(procexp)和tasklist /m <locked_dll.dll>搜索保留在此dll上的内容,而找不到任何保留在dll上的东西。 I'm on a non-admin account, and I'm not sure if that is causing Windows to hide certain processes from me. 我使用的是非管理员帐户,我不确定这是否导致Windows向我隐藏某些进程。 Rebooting the machine helps, but that's not an acceptable solution since I'm trying to automate things. 重新启动计算机会有所帮助,但这不是可接受的解决方案,因为我正在尝试使事情自动化。 I'm able to delete the .dll, and when I try to build the project in VS, it'll complain that it still can't access the dll when trying to copy it over to the Bin folder. 我能够删除.dll,并且当我尝试在VS中构建项目时,它会抱怨说,在尝试将其复制到Bin文件夹时,它仍然无法访问该dll。 Any ideas? 有任何想法吗? I'm going to keep researching the issue, but as of right now, I'm sort of stumped. 我将继续研究该问题,但截至目前,我有些沮丧。

EDIT: This seems to be a duplicate question ( Error: Cannot access file bin/Debug/... because it is being used by another process ), but I'll leave this open to see if anyone has found anything new related to the topic. 编辑:这似乎是一个重复的问题( 错误:无法访问文件bin / Debug / ...,因为它正在被另一个进程使用 ),但是我将保持打开状态,以查看是否有人找到了与话题。

I've seen this problem in VS 2010 with a large .Net solution with multiple projects in it. 我已经在VS 2010中看到了这个问题,它带有一个包含多个项目的大型.Net解决方案。 Every case I've seen so far pertains to have one project with dependency DLLs that another project also uses, and that other project also uses the first project as a reference, and also uses the same dependency DLLs that happen to be a different version from the first project. 到目前为止,我所看到的每种情况都涉及到一个项目具有另一个项目也使用的依赖项DLL,而另一个项目也使用第一个项目作为参考,并且还使用了相同的依赖项DLL,而该DLL恰好与版本不同。第一个项目。

To describe it a different way: 用不同的方式描述它:

Project A depends on v1 of DLL A 项目A取决于DLL A的v1

Project B depends on project A and v2 of DLL A 项目B取决于项目A和DLL A的v2

Both project A and B are in the same solution 项目A和项目B都在同一个解决方案中

The solution is to use the same version of DLL A. I usually run into this when upgrading to a new version of SQLite, and I forget to update the dependency in all of my projects. 解决方案是使用相同版本的DLLA。在升级到新版本的SQLite时,我通常会遇到此问题,而我忘了更新所有项目中的依赖项。

After talking with a few coworkers, I found the solution to my problem. 与几个同事交谈后,我找到了解决问题的方法。 procexp and tasklist did not see which process was locking the dll because there was no process locking the dll on that particular machine. procexp和tasklist看不到哪个进程正在锁定dll,因为在特定计算机上没有进程锁定dll。

I have a hardware configuration where machine A (a host PC) is connected to machine B (acts as a client that retrieves instructions from machine A) using a network switch. 我有一个硬件配置,其中使用网络交换机将机器A(主机PC)连接到机器B(充当从机器A检索指令的客户端)。 machine B runs the same binaries that link to the same dll's. 机器B运行链接到相同dll的相同二进制文件。 Thus, obviously, running procexp or tasklist on machine A will not see anything locking the dll's because machine B is the culprit. 因此,显然,在机器A上运行procexp或tasklist不会看到锁定dll的任何内容,因为机器B是罪魁祸首。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM