vb.net 如何从 Visual Studio 2013 调试引用的 DLL 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24389455/
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
How can I debug a referenced DLL file from Visual Studio 2013?
提问by JuiCe
To start, I know this question has been asked a million times all over the place, but as I have no experience with VB/Visual Studio, I can't find a solution that I can make sense of.
首先,我知道这个问题已经被问了一百万次,但由于我没有使用 VB/Visual Studio 的经验,我找不到我能理解的解决方案。
I am creating a new VB.net project(solution?), and am making calls to functions from a C librarythat are in a dllfile. The dllfile does have a pdbfile and they are both stored at the same location.
我正在创建一个new VB.net project(solution?),并且正在从文件C library中的 a调用函数dll。该dll文件确实有一个pdb文件,并且它们都存储在同一位置。
In the code below it shows how I declare the functions in my VB.netcode, but I have not figured out how to attach the pdbfile to the project.
在下面的代码中,它显示了我如何在代码中声明函数VB.net,但我还没有弄清楚如何将pdb文件附加到项目中。
Declare Function InitRelay Lib "Z:\Devel\RelayAPI\Debug\RelayAPI.dll" (ByVal setbaud As Action(Of Short), ByVal getit As Func(Of Short, Short), ByVal putit As Action(Of Short), ByVal flushit As Action, ByVal delay As Action(Of Short)) As Byte
Declare Sub FreeRelay Lib "Z:\Devel\RelayAPI\Debug\RelayAPI.dll" ()
...
I am getting an exception somewhere in the DLL file, but the way I have it set up, I can not debug the dll file. Whether its adding breakpoints, or print statements, I need a way to see where in the dllthe project fails.
我在 DLL 文件中的某处遇到异常,但按照我的设置方式,我无法调试 dll 文件。无论是添加断点还是打印语句,我都需要一种方法来查看dll项目失败的位置。
Questions I have looked at:
我看过的问题:
- How to debug a referenced dll- I tried following the menu path given in the accepted answer, but when I go to Project >> Project PropertiesI see no Buildoption. It also says I can load symbols directly in the IDE if I don't want to copy any files, but I cannot find an explanation on how to do it. EDIT - As Plutonix says below, C# Build is the equivalent of VB's Compile tab. I checked and my
Debug Infois set toFull, so this does not solve my problem. - Debugging a third-party DLL in Visual Studio?- This talks about a
DLLin a.NETlanguage but mine is in C. It also only tells you how to view the code, which I already can do. I have access to the .c and .h files that are used to create thedll, I just cannot debug them at runtime.
- 如何调试引用的 dll- 我尝试按照接受的答案中给出的菜单路径进行操作,但是当我转到Project >> Project Properties 时,我看不到Build选项。它还说如果我不想复制任何文件,我可以直接在 IDE 中加载符号,但我找不到有关如何执行此操作的说明。编辑 - 正如 Plutonix 在下面所说,C# Build 相当于 VB 的 Compile 选项卡。我检查过,我
Debug Info的设置为Full,所以这不能解决我的问题。 - 在 Visual Studio 中调试第三方 DLL?- 这谈的
DLL是一种.NET语言中的 a但我的是 C 中的。它也只告诉你如何查看代码,我已经可以做到了。我可以访问用于创建 .c 和 .h 文件,但dll我无法在运行时调试它们。
回答by AH Tek
When you debug a DLL, you can start debugging from: The project used to create the executable that calls the DLL. - or -The project used to create the DLL itself.
调试 DLL 时,可以从以下位置开始调试: 用于创建调用 DLL 的可执行文件的项目。 - 或 -用于创建 DLL 本身的项目。
There are a couple of ways to debug a reference DLL file using VS 2013, so here the method Microsoft uses
有几种方法可以使用 VS 2013 调试参考 DLL 文件,所以这里使用 Microsoft 的方法
-->To specify an executable for the debug session
-->为调试会话指定一个可执行文件
- In Solution Explorer, select the project that creates the DLL.
- From the Viewmenu, choose Property Pages.
- In the Property Pagesdialog box, open the Configuration Propertiesfolder and select the Debuggingcategory.
- In the Command box, specify the path name for the container. For example, C:\Program Files\MyApplication\MYAPP.EXE.
- In the Command Argumentsbox, specify any necessary arguments for the executable.
- 在解决方案资源管理器中,选择创建 DLL 的项目。
- 从视图菜单中,选择属性页。
- 在“属性页”对话框中,打开“配置属性”文件夹并选择“调试”类别。
- 在命令框中,指定容器的路径名。例如,C:\Program Files\MyApplication\MYAPP.EXE。
- 在命令参数框中,为可执行文件指定任何必要的参数。
Here I included 2 different methods for debugging a DLL file directly from Microsoft.
在这里,我包含了 2 种不同的方法来直接从 Microsoft 调试 DLL 文件。
1> http://msdn.microsoft.com/en-us/library/605a12zt.aspx(Native Mode)
1> http://msdn.microsoft.com/en-us/library/605a12zt.aspx (本机模式)
2> http://msdn.microsoft.com/en-us/library/kbaht4dh.aspx(Mixed Mode)
2> http://msdn.microsoft.com/en-us/library/kbaht4dh.aspx (混合模式)
If this was anyhelp to you or solved your problem please make sure to drop a "vote up"
如果这对您有帮助或解决了您的问题,请确保放弃“投票”
Ref.All information is from personal experience and Microsoft
参考 所有信息均来自个人经验和微软

