How to use the Visual Studio .NET or Visual Studio 2005 native debugger to debug a Visual Basic 6.0 DLL when it is called from an ASP.NET application (811658)
The information in this article applies to:
- Microsoft Visual Basic 2005
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic .NET (2002)
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
- Microsoft ASP.NET (included with the .NET Framework 1.1)
- Microsoft ASP.NET (included with the .NET Framework) 1.0
SUMMARYThis step-by-step article describes how to use the Microsoft
Visual Studio .NET or Microsoft Visual Studio 2005 native debugger to debug a Microsoft Visual Basic 6.0 DLL
when it is called from an ASP.NET application. To debug Visual Basic
applications, use one of the following methods:
- Use the Visual Basic development environment.
When you
debug in the development environment, you use
P-code. P-code
is an interpreted language that permits you to debug in the
development environment.
-or- - Use the native debugger if problems do not appear when you debug in the
Visual Basic development environment, but problems do appear in the compiled
version.
This article describes how to use the second method to debug a
Visual Basic 6.0 DLL that is being used in ASP.NET. You debug the DLL by using
the same binary that the DLL runs with (not including any optimizations). This creates
an
execution that is easier to debug than the P-code that you receive
when you debug in the Visual Basic development environment. back to the topRequirementsThe following list outlines the recommended hardware,
software, network infrastructure, and service packs that are required:
- Microsoft Visual Studio .NET or Microsoft Visual Studio 2005
- 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 or Microsoft Visual Basic 2005 syntax
- Microsoft Visual Basic 6.0 syntax
- Microsoft Visual Studio .NET or Microsoft Visual Studio 2005 environment
back to the topCreate the Visual Basic 6.0 DLL- In the Visual Basic 6.0 IDE, click New Project on the File
menu.
- In the New Project dialog box, click to
select ActiveX DLL, and then click
OK.
- On the View Menu, click Properties.
- On the Properties dialog box drop-down
list, click Class1.
- Change the Name property to
VB6Class.
- Add the following code to your class to create a public
method in your class:
Public Function showButtonValue() As Integer
showButtonValue = 1000
End Function
- On the Project menu, click
Project1
Properties.
- Click the Compile tab, and then click to
select No Optimization.
- Click to select the
Create Symbolic Debug Info
check box.
- Click the General tab, change
Project
Name to VB6DlltoCall,
and then click OK.
- On the File menu, click Make
VB6DlltoCall.dll.
- Click to select the Visual Basic 6.0 folder, and then click OK to save
VB6DlltoCall.dll.
Note Your Visual Basic 6.0 project is stored in the Visual Basic 6.0 folder. - On the Project menu, click
VB6DlltoCall Properties.
- Click the Component tab, click to select
Binary Compatibility, and then click
OK.
- On the File menu, click Save
Project, and then click the Visual Basic 6.0 folder to save the class and project file.
Note VB6Class.cls is the name of the class file that you debug.
Therefore, you can just accept the default names. - On the File menu, click Make
VB6DlltoCall.dll.
Note When you create the file a second time, you receive a message
about overwriting the existing file. Permit the compiler to overwrite the
existing DLL. - On the File menu, click
Exit to close the Visual Basic 6.0 project.
- Open the Visual Basic 6.0 folder that contains the DLL.
- Right-click the DLL, and then click to select
Properties.
- Click the Security tab.
- Click the Add button.
- Type Computer Name\ASPNET, and
then click Check Name to verify that you locate the ASP.NET
account.
Note Replace Computer Name with the name of your computer. The ASP.NET account is the user
account that the ASP.NET worker process executes under. If you do not permit this account to
execute your DLL, your class is not created, and it fails with an "Access Denied"
error. - Click OK.
- Verify that Read & Execute is checked
for the ASP.NET account, and then click OK.
back to the topCreate the ASP.NET Project in Visual Studio .NET- Start Visual Studio .NET.
- On the File menu, point to
New, and then click Project.
- In the New Project dialog box, click to
select Visual Basic Projects under Project
Types, and then click to select ASP.NET Web
Application under Templates.
- In the Location text box, type the project
name as http://localhost/MyASPnetProject.
Note In the project name, http://localhost creates the
application on your local server. - Click OK to create the project.
Create the ASP .NET 2.0 Project in Visual Studio 2005- Start Visual Studio 2005.
- On the File menu, point to
New, and then click Web Site.
- In the New Web Site dialog box, click ASP .NET Web Site under Templates.
- In the Location box, click HTTP, and then type the project
name as http://localhost/MyASPnetProject.
Note In the project name, http://localhost creates the
application on your local server. - Click Visual Basic in the Language box, and then click OK to create the project.
back to the topDebug- In the ASP.NET project, click the
Project menu, and then click Add
Reference.
- Click Browse, and then click VB6DlltoCall.dll (created earlier).
- Click Open, and then click
OK.
Note In Visual Studio 2005, you do not have to click Open. - Add a button from the toolbox to Webform1.aspx.
- Double-click Button, and then add
the following code to the
Button1_Click
event in
Webform1.aspx.vb:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cls As New VB6DlltoCall.VB6ClassClass()
Button1.Text = cls.showButtonValue
End Sub - On the Build menu, click Build
Solution.
- On the Debug menu, click Start
Without Debugging.
Note Start the application that you created one
time without debugging to make sure that the ASP.NET worker process is started,
and that you can
attach to the worker process in the
next
step. - On the Debug menu, click
Processes.
- In the Processes dialog box, click to
select aspnet_wp.exe under Available
Processes, and then click Attach.
- In the Attach to Process dialog box, click
to select the Native check box and the Common Language
Runtime check box.
Note If you do not have the native debugging option, you do not have
Microsoft Visual C++ .NET or Microsoft Visual C++ 2005 installed. You must install Visual C++ .NET or Visual C++ 2005 for the
debugging to work correctly. - Click OK, and then click
Close.
Note When you click OK,
the debugger may take up to five minutes to
attach. - In the Visual Studio .NET or Visual Studio 2005 IDE, point to
Open on the File menu, and then click
File.
- Click the Visual Basic 6.0 class file
(VB6Class.cls),
and then click Open.
- Set a break point in the VB6Class.cls file on the following
code line:
showButtonValue = 1000
- Switch to the Web browser window that was open with the
.aspx page when you clicked Start Without Debugging in step 7.
- Click Button on the Webform.aspx page.
This hits the break point in the Visual Basic 6.0 class file. back to the
topREFERENCES For
additional information, click the following article numbers to view the
articles in the Microsoft Knowledge Base: 170946
How To Create and Use a Minimal ActiveX Component in VB
303845 How To Create or Open a Visual Studio .NET Project in the Root Web
Modification Type: | Minor | Last Reviewed: | 10/3/2006 |
---|
Keywords: | kbvs2005applies kbvs2005swept kbWebForms kbDLL kbCOMInterop kbweb kbDebug kbHOWTOmaster KB811658 kbAudDeveloper |
---|
|
|
©2004 Microsoft Corporation. All rights reserved.
|
|