visual-studio 为什么 Visual Studio 的模块列表中缺少加载的 dll?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3582864/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 12:23:18  来源:igfitidea点击:

Why is loaded dll missing in Visual Studio's modules list?

visual-studiovisual-studio-2005

提问by Hatch

I am currently bug hunting and need to debug into a specific dll in the release configuration in Visual Studio 2005. At some point I closed the solution, did some other stuff and reloaded it. From that point on my breakpoint doesn't get hit and I get the infamous "No symbols have been loaded..." message. So I opened the modules window and the dll that I want to debug doesn't appear in the list anymore, therefore I cannot load symbols manually. The application behaves normal so I am absolutely sure that the dll MUST have been loaded to execute certain functions. Sure enough, if I rename the dll and start up the application it doesn't work anymore, so it also must be the right dll.

我目前正在寻找错误,需要在 Visual Studio 2005 的发布配置中调试到特定的 dll。在某个时候我关闭了解决方案,做了一些其他的事情并重新加载了它。从那时起,我的断点没有被击中,我收到了臭名昭著的“没有加载符号......”消息。所以我打开了模块窗口,我想调试的 dll 不再出现在列表中,因此我无法手动加载符号。应用程序运行正常,所以我绝对确定必须加载 dll 才能执行某些功能。果然,如果我重命名dll并启动应用程序,它就不再工作了,所以它也必须是正确的dll。

I tried setting the dll project as startup project and the command to execute to the application's exe and starting the application from outside visual studio and then attaching to the process, all to no avail.

我尝试将 dll 项目设置为启动项目,并将命令执行到应用程序的 exe 并从 Visual Studio 外部启动应用程序,然后附加到该进程,但都无济于事。

Question is, why is the dll not appearing in the list of loaded modules although it must have been loaded? I cannot think of any other changes that I've done, that could cause this, am I missing something? (Maybe something really obvious?)

问题是,为什么 dll 没有出现在加载模块列表中,尽管它必须已经加载?我想不出我做过的任何其他更改,这可能会导致这种情况,我错过了什么吗?(也许真的很明显?)

Any help appreciated!

任何帮助表示赞赏!

采纳答案by Josh Campbell

I encountered a similar issueafter transferring a project from one computer to another. I will simply explain what I discoveredand how I fixed it, and you can determine if it fits your problem and solution.

将项目从一台计算机转移到另一台计算机后,我遇到了类似的问题。我将简单地解释我发现的内容以及我如何修复它,您可以确定它是否适合您的问题和解决方案。

  1. The work computer I wrote an application on contained a .dll file which my program was referencing. After moving the application to my home computer, the application could no longer locate the .dll file it was previously referencing because the file was no longer there.

  2. The application compiled and ran even without the referenced resource (.dll file) because the previously compiled assembly (debug folder) contained its own copy of the .dll file and other resources. Put simply, it is the old assembly build that is running and not the current application you're working on. This is also why this error tends to suspend the designer window and throw an error after the app is done running.

  1. 我在其上编写应用程序的工作计算机包含一个我的程序引用的 .dll 文件。将该应用程序移至我的家用计算机后,该应用程序无法再找到它之前引用的 .dll 文件,因为该文件不再存在。

  2. 即使没有引用的资源(.dll 文件),应用程序也会编译和运行,因为之前编译的程序集(调试文件夹)包含自己的 .dll 文件副本和其他资源。简而言之,运行的是旧的程序集版本,而不是您正在处理的当前应用程序。这也是为什么这个错误往往会挂起设计器窗口并在应用程序运行完成后抛出错误。

I would take a look at the following:

我会看看以下内容:

a) Under Solution Explorer, go into the Referencesfolder and right click the missing reference nodeand select properties. In the properties box, observe the Pathof the resource being referenced. Is the resource still located at this path?

a) 在“解决方案资源管理器”下,进入“引用”文件夹并右键单击缺少的引用节点并选择“属性”。在属性框中,观察所引用资源的路径资源是否仍位于此路径?

b) Check the debug folderfor a copy of the resource you're looking for. If the resource is there, make a copyand save it to your desktop. If it's not there, get the file from the original source.

b)检查调试文件夹中是否有您要查找的资源的副本。如果资源在那里,请复制一份并将其保存到您的桌面。如果它不存在,请从原始来源获取文件

c) Under Solution Explorer, right click 'Properties' and 'open'. From the menu that appears select 'Resources' from the left and at the top of the new window that appears you you should see 'Add Resource' with a small drop down arrow. Click the arrowand select 'Add existing file' and then browse to the file. If you don't see it you may have to change the file being browsed from the small drop down above the 'open' and 'Cancel' buttons. After the file is located it should create a new folder in the solution explorer called 'resources.' Now the file is a permanent part of your application and not merely a reference to it.

c)在解决方案资源管理器下,右键单击“属性”和“打开”。从出现的菜单中选择左侧的“资源”,在出现的新窗口顶部,您应该会看到带有小下拉箭头的“添加资源”。单击箭头并选择“添加现有文件”,然后浏览到该文件。如果您没有看到它,您可能需要从“打开”和“取消”按钮上方的小下拉菜单中更改正在浏览的文件。找到文件后,它应该在解决方案资源管理器中创建一个名为“资源”的新文件夹。

回答by KShukla

  1. Use process explorer to check if the dll is loaded or not.

  2. When you attach the process make sure that you are enabling both 'Native' and 'Managed' code type (in the code type selection option).

  1. 使用进程资源管理器检查 dll 是否已加载。

  2. 当您附加流程时,请确保您同时启用“本机”和“托管”代码类型(在代码类型选择选项中)。

See also this question: Visual Studio is not loading modules when attaching to process

另请参阅此问题:Visual Studio 在附加到进程时未加载模块

回答by Fremen

I had the same issue today with Visual Studio 2008. I was using a simple tester to test a new method in an assembly. So added a reference to my assembly I wrote the code to load the assembly and call the new method, build, everything OK. But during execution the debugger would throw an exception saying that new new method did not exist, and the modules window was empty.

我今天在 Visual Studio 2008 中遇到了同样的问题。我使用一个简单的测试器来测试程序集中的新方法。所以添加了对我的程序集的引用,我编写了代码来加载程序集并调用新方法,构建,一切正常。但是在执行过程中,调试器会抛出一个异常,说新的新方法不存在,并且模块窗口是空的。

Turns out the assembly I was modifying was in the GAC, and was using instead of the new one in my build directory.

原来我正在修改的程序集在 GAC 中,并且在我的构建目录中使用而不是新的。