HOWTO: Debug a Native Code Visual Basic Component in VC++Last reviewed: November 24, 1997Article ID: Q166275 |
The information in this article applies to:
SUMMARYThe Visual Basic 5.0 debugger allows you to debug your code at design time before you compile it into an .exe, .dll, or .ocx. If you are debugging Visual Basic-created COM components, you can debug them out-of-process by running multiple projects in the same instance of Visual Basic 5.0, or by running separate instances of Visual Basic 5.0 with the client running in one and the COM component running in the other. If you want to debug your components after they are compiled, you cannot use the Visual Basic 5.0 debugger because it will only debug them at design time. To debug a compiled Visual Basic component, you will need to use the functionality of the Visual C++ 5.0 debugger. The following are situations when you may need to debug a compiled Visual Basic component:
MORE INFORMATIONThe following steps assume that you already have a Visual Basic 5.0-created Standard EXE (.exe), ActiveX DLL (.dll), ActiveX EXE (.exe), or ActiveX Control (.ocx) that you want to debug.
then Go, or press the F5 key. When your Visual Basic compiled component reaches the line you set a breakpoint on, it will stop in Visual C++ 5.0 and allow you to perform normal debug operations.4b. ActiveX EXE, DLL, or OCX: It is a little different for DLLs in that you have to specify an exe to debug with. To do this, from the Project menu select Settings, and then click the Debug tab. In the Executable for debug session text box specify the .exe file that references your .dll. Now follow step 4a which will launch your executable and your .dll and the Visual C++ 5.0 debugger will come up where you set the breakpoint in your .dll.4c. ActiveX DLL Running Under Microsoft Transaction Server (MTS): To set this up, select Settings from the Visual C++ 5.0 Project menu, and then click the Debug tab. In the Executable for debug session text box, specify MTX.EXE. Then, in the Program arguments text box place /p:{00000000-0000- 0000-0000- 000000000000} where you would replace the 0's with the actual MTS Package ID. The Package ID can be obtained by examining the properties of your package in the Transaction Server Explorer. Following step 4a above which will launch MTX.EXE and your .dll. Now run the base client .exe that makes a call into your COM component running under MTS and the Visual C++ 5.0 debugger will come up where you set the breakpoint in your .dll.4d. ActiveX DLL Running Under Internet Information Server (IIS): Because IIS runs as an NT Service, you will need to give yourself permission to act as part of the operation system. To do this, go to NT Administrative Tools and select User Manager. If you are using User Manager for Domains in NT Server, make sure you have selected your machine name as the Domain from the File menu. Then, choose User Rights from the Policies menu. In the User Rights dialog box, place a check next to Show Advanced User Rights and select "Act as part of the operating system" from the combo box. Click the Add button and type in "domainxxx\userxxx" in the text area, or select your username from the listbox. Click OK and you should now have the correct privileges. To start the debugging session in Visual C++ 5.0, go to the Build menu, select Start Debug, then Attach to Process. Place a check next to Show System Processes, then select inetinfo and click OK. Now load a client .htm or .asp file that will make a call into your ActiveX component. If you follow the directions in step 3 above, you should now be able to walk through your Visual Basic code.Another Visual C++ feature is the ability to do cross-process and cross- machine debugging. If you are running in a debugger and call a .dll that has debugging info, it will automatically start another instance of the debugger and the source so that you can debug into it. Note that if the .exe is compiled optimized for size or speed, lines of dead code will be compiled out of the project.
REFERENCES(c) Microsoft Corporation 1997, All Rights Reserved. Contributions by Jon Fowler, Microsoft Corporation
|
Additional query words: MTS MTX VIPER
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |