How to Implement combined debugging of VB and VC

Source: Internet
Author: User

I wrote a DLL using VC and then wrote the EXE using VB.
I want to debug my DLL and EXE In the VB environment, but I cannot jump into the DLL function and debug it in the DLL.
Is there a way for me to implement VB and VC joint debugging? When I need to jump into the DLL function in the VB environment, enter the VC environment and debug in the VC, in this way, I can view the variable value, set the breakpoint, and continue debugging when the function returns to the VB environment.
 
Later, after some exploration, I finally achieved the VB and VC joint debugging.
 
This method uses VC as the main environment and VB as the secondary environment. This is because the DLL is compiled by VC, and we usually need to specify an EXE when debugging the DLL. If the DLL is written in VB, I think it should be based on VB (not tested ).
 
1. Create a VB Standard EXE project project1.vbp, in which the function of the dynamic connection library written by VC is called.
2. Create a vc dll project TestDll and write code to implement function output. We recommend that you place the entire project directory in the directory where project1.vbp is located.
3. Setting up the VC project. This step is very important and is the key to implementing joint debugging.
A) change the OutPut Files path on the General tab and specify the directory where project1.vbp is located. Because I put the project directory under the project1.vbp directory, I use the relative path "..." (actually the directory where project1.vbp is located ).
B) Change Executable for Debug session on the debug tab: vb6.exe on the worker computer; change Working directory to the directory where project1.vbp is located; enter project1.vbp in Program arguments:, which is actually passed to VB, open project1.vbp in VB. If the parameter "/r" is added, start immediately after VB is started (equivalent to pressing F5). If the parameter "/r" is not added, start manually.
C) confirm the DLL path and DLL name output in your Link tab, and set it to the directory where project1.vbp is located:
4. Set the breakpoint in your DLL source program (VC), press F5, GO! How about it? The VB environment is running, and the project project1.vbp has already been opened! If you are at 3) B. the "/r" parameter is specified in Program arguments: So the Program has started running. If this parameter is not specified, you can set the breakpoint in the VB environment first, then, set the breakpoint on the DLL function, and press F5, Start! If you encounter a breakpoint in VB, the program will stop, and then press F8, Step! What have you found? haha, the VC environment proactively switches to the front, and the current arrow has already pointed to the called function. At this time, it has already entered the VC environment. You can do whatever you want to debug it! When the called function ends, press F11 and Step Out. Otherwise, there will be a piece of assembly code. At this time, the VB environment has proactively switched to the front and entered the VB debugging environment!
 
When compiling DLL with VC, note that VC will modify the name of the output function. Therefore, you still need to specify the name of the output function in the def file. This method is applicable to other environments (such as Delphi-VC and Delphi-VB). I have not tested it yet. Please test it as needed.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.