HOW TO: When calling Microsoft Visual Basic 6.0 DLL from an ASP.NET application, use Microsoft Visual Studio .Net Native Detector to debug it
Article ID: 811658 Last Update Date: September 15, 2003 Version: 2.0
This task content
•summary
• Requirements • Creating a Visual Basic 6.0 DLL • Create an ASP.NET • Debugging • Reference
This page
Summary reference
summary
This article gradually introduces how to debug it using Microsoft Visual Studio .NET Native DLL from the ASP.NET application calls Microsoft Visual Basic 6.0 DLL.
To debug Visual Basic applications, use one of the following methods:
• Develop environments using the Visual Basic. Use P-code when commissioning in the development environment. P-code is an interpretation language that you can debug in a development environment. - Or - • If there is no problem in the Visual Basic development environment, there is no problem in the compiled version, and the native adjustment should be used. This article describes how to use the second method to debug the Visual Basic 6.0 DLL used in ASP.NET. You should use the same binary debugging DLL (excluding any optimization) as used by DLL runtime. This will create an execution process, which is easy to debug the P-code received when you are commissioning in the Visual Basic development environment.
Back to top
Claim
The following summarizes the recommended hardware, software, network structure, and service pack required:
• Microsoft Visual Studio .NET • Microsoft Visual Basic 6.0 • Microsoft Internet Information Services (IIS) 5.0 or later This article assumes that you are familiar with the following topics:
• Microsoft Visual Basic .NET Syntax • Microsoft Visual Basic 6.0 Syntax • Microsoft Visual Studio .NET
Back to top
Create Visual Basic 6.0 DLL
1. In Visual Basic 6.0 IDE, click New Project on the File menu. 2. In the New Project dialog box, click to select "ActiveX DLL" and click OK. 3. On the View menu, click Properties. 4. In the drop-down list of the Properties dialog box, click Class1. 5. Change the "Name" property to VB6Class. 6. Add the following code to your class to create a public method in the class: public function showbuttonvalue () AS Integer
ShowbuttonValue = 1000
END FUNCTION
7. On the Projects menu, click "Project1 Properties". 8. Click the Compilation tab, and then click to select "No Optimization". 9. Click to select the Create Symbol Debug Information check box. 10. Click the General tab to change the Project Name to VB6DLLTOCALL, and then click OK. 11. On the File menu, click Generate VB6dlltocall.dll. 12. Click to select the Visual Basic 6.0 folder, and then click OK to save VB6dlltocall.dll. Note: Visual Basic 6.0 project is stored in the Visual Basic 6.0 folder. 13. On the Projects menu, click VB6DLLTOCALL Properties. 14. On the Component tab, click to select "Binary Compatibility" and click OK. 15. On the File menu, click Save Project, and then click the Visual Basic 6.0 folder, save classes, and project files. Note: vb6class.cls is the name of the class file you debug. Therefore, you only need to accept the default name. 16. On the File menu, click Generate VB6DLLTOCALL.DLL. Note: When you create this file again, a message will appear, the prompt overwrites the existing file. Allow the compiler to overwrite the existing DLL. 17. On the File menu, click "Exit" to close the Visual Basic 6.0 project. 18. Open the "Visual Basic 6.0" folder that contains the DLL. 19. Right-click the DLL, then click to select "Properties". 20. Click the Security tab. 21. Click the Add button. 22. Type the computer name / aspnet, and then click "Check Name" to verify that you find the ASP.NET account. Note: Replace the computer name with your computer name. The ASP.NET account is the user account in which the ASP.NET assisted process is executed. If you prohibit this account to execute a DLL, you will not create classes, and it will fail because of "Access Denied" error. 23. Click OK. 24. Verify that "Reading and Execution" is selected for the ASP.NET account, and then click OK. Back to top
Create an ASP.NET project
1. Start "Visual Studio .NET". 2. On the File menu, point to "New" and click Project. 3. In the New Project dialog box, click "Visual Basic Project" under Project Type, then click to select "ASP.NET Web Application" under Template. 4. In the Location text box, type the http: // local host /ASP.NET project as the project name. Note: In the project name, "HTTP: // Local Host" will create an application on your local server. 5. Click "OK" to create a project.
Back to top
debugging
1. In the ASP.NET project, click the Item menu, and then click Add Reference. 2. Click Browse, and then click VB6dllTocall.dll (previously created). 3. Click Open, and then click OK. 4. Add the buttons in the toolbox to WebForm1.aspx. 5. Double-click the "button" and then add the following code to "Button1_Click" event in Webform1.aspx.vb: Private Sub Button1_Click (Byval E AS System.EventArgs) Handles Button1.click
DIM CLS as new vb6dlltocall.vb6classclass () Button1.text = CLS.SHOWBUTTONVALUE
End Sub6. On the Generate menu, click Generate Solutions. 7. On the Debug menu, click "Start execution (not debug)". Note: Start the created application in the case of not debugging to ensure that the ASP.NET assist process starts and you can attach the auxiliary process in the next step. 8. On the Debug menu, click Process. 9. In the Process dialog box, click "ASPNET_WP.exe" under the "Available Process" and click Additional. 10. In the Attached To Process dialog box, click to select the "Native" checkbox and "Public Language Runture" checkbox. Note: If there is no this modulation option, the Microsoft Visual C .NET is not installed. Visual C .NET must be installed and debugged to work correctly. 11. Click OK, and then click Close. Note: If you click OK, the debugger may take five minutes to attach. 12. In the Visual Studio .NET IDE, point to "Open" on the File menu, and then click File. 13. Click the "Visual Basic 6.0" class file (VB6Class.CLS), then click Open. 14. Set the interrupt point in the following code line in the VB6Class.cls file: showbuttonvalue = 1000
15. Switch to the web browser window, which is you open when you click "Start" Start (Not Debug) "in step 7 .ASPX page. 16. Click the button on the WebForm.aspx page. This will hit the interrupt point in the Visual Basic 6.0 class file.
Back to top
reference
For additional information, click the article number below to see the article in the Microsoft Knowledge Base:
170946 HOWTO: CREATE AND USE A Minimal ActiveX Component In VB
303845 HOWTO: CREATE OROPEN A Visual Studio .NET Project in the root web
The information in this article applies to:
• Microsoft Visual .NET 2002 Standard Edition • Microsoft ASP.NET (Included with The .NET Framework) 1.0 • Microsoft Visual Basic 6.0 Professional Edition • Microsoft Visual Basic 6.0 Enterprise Edition • Microsoft Visual Basic .NET 2003 Standard Edition • Microsoft ASP.NET (Included with the .NET Framework 1.1)
Back to top
Keywords: kbwebforms kbdll kbcominterop kbweb kbdebug kbhowtomaster kb811658