Link to home
Start Free TrialLog in
Avatar of SirReadAlot
SirReadAlot

asked on

Debugging Classic ASP Code

Hi guys,

I saw this nice article...and I would like to debug asp code in 2005.

I read this article and I am not too sure about step 2.

can you explain?

http://blogs.msdn.com/greggm/archive/2006/03/15/552108.aspx
thanks
Avatar of nauman_ahmed
nauman_ahmed
Flag of United States of America image

Open IIS Manager
Right click on your web site and select Properties -> Home Directory -> Configuration -> Debugging tab.

--Nauman.
Avatar of SirReadAlot
SirReadAlot

ASKER

yes done that  i don't understand step 2
this

#2. Since the debugger doesn’t have support for ASP Auto-Attach, you can’t just press F5. But what you can do is to hit your page in IE, and use the below macro to automatically start debugging the ASP code. You can assign a macro to a key, so within 2 minutes, you can have Ctrl-Shift-F5 (or whatever key you want), setup to automatically attach to the worker process and get a pretty similar experience to what you have always had.

    Sub ClassicASPAttach()

        Try

            Dim os As System.Version = System.Environment.OSVersion.Version

            Dim IISProcess As String = "w3wp.exe"

 

            If os.Major = 5 And os.Minor < 2 Then

                IISProcess = "dllhost.exe"

            End If

 

            Dim processFound As Boolean = False

 

            Dim process As EnvDTE80.Process2

            For Each process In DTE.Debugger.LocalProcesses

 

                'Determine if the process could the IIS worker process

                Dim processName As String = process.Name.ToLowerInvariant()

                Dim processBaseName As String = System.IO.Path.GetFileName(processName)

                If Not processBaseName = IISProcess Then

                    If Not processBaseName = "inetinfo.exe" Then

                        Continue For

                    End If

                End If

 

                'Determine if the process contains asp.dll

                Dim aspLoaded As Boolean = False

                Dim diagProcess As System.Diagnostics.Process = System.Diagnostics.Process.GetProcessById(process.ProcessID)

                Dim diagModule As System.Diagnostics.ProcessModule

                For Each diagModule In diagProcess.Modules

                    Dim moduleName As String = System.IO.Path.GetFileName(diagModule.FileName).ToLowerInvariant()

                    If moduleName = "asp.dll" Then

                        aspLoaded = True

                        Exit For

                    End If

                Next

 

                'If the process contains asp.dll, attach to it

                If aspLoaded Then

                    process.Attach2("Script")

                    processFound = True

                End If

            Next

 

            If Not processFound Then

                MsgBox("Could not find this IIS process. Hit a web page containing classic ASP script so that the process will start.")

            End If

 

        Catch ex As System.Exception

            MsgBox(ex.Message)

        End Try

    End Sub

 
ASKER CERTIFIED SOLUTION
Avatar of samtran0331
samtran0331
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
will try this

thanks
Can u help me setup this in visual studio 2005.
Do I need both functions:
 Sub ClassicASPAttach()



        Try

            Dim os As System.Version = System.Environment.OSVersion.Version

            Dim IISProcess As String = "w3wp.exe"



            If os.Major = 5 And os.Minor < 2 Then

                IISProcess = "dllhost.exe"

            End If



            Dim processFound As Boolean = False



            Dim process As EnvDTE80.Process2

            For Each process In DTE.Debugger.LocalProcesses



                'Determine if the process could the IIS worker process

                Dim processName As String = process.Name.ToLowerInvariant()

                Dim processBaseName As String = System.IO.Path.GetFileName(processName)

                If Not processBaseName = IISProcess Then

                    If Not processBaseName = "inetinfo.exe" Then

                        Continue For

                    End If

                End If



                'Determine if the process contains asp.dll

                Dim aspLoaded As Boolean = False

                Dim diagProcess As System.Diagnostics.Process = System.Diagnostics.Process.GetProcessById(process.ProcessID)

                Dim diagModule As System.Diagnostics.ProcessModule

                For Each diagModule In diagProcess.Modules

                    Dim moduleName As String = System.IO.Path.GetFileName(diagModule.FileName).ToLowerInvariant()

                    If moduleName = "asp.dll" Then

                        aspLoaded = True

                        Exit For

                    End If

                Next



                'If the process contains asp.dll, attach to it

                If aspLoaded Then

                    process.Attach2("Script")

                    processFound = True

                End If

            Next



            If Not processFound Then

                MsgBox("Could not find this IIS process. Hit a web page containing classic ASP script so that the process will start.")

            End If



        Catch ex As System.Exception

            MsgBox(ex.Message)

        End Try

    End Sub

    Sub ClassicASPDetach()



        Try

            Dim os As System.Version = System.Environment.OSVersion.Version

            Dim IISProcess As String = "w3wp.exe"



            If os.Major = 5 And os.Minor < 2 Then

                IISProcess = "dllhost.exe"

            End If



            Dim processFound As Boolean = False



            Dim process As EnvDTE80.Process2

            For Each process In DTE.Debugger.LocalProcesses



                'Determine if the process could the IIS worker process

                Dim processName As String = process.Name.ToLowerInvariant()

                Dim processBaseName As String = System.IO.Path.GetFileName(processName)

                If Not processBaseName = IISProcess Then

                    If Not processBaseName = "inetinfo.exe" Then

                        Continue For

                    End If

                End If



                'Determine if the process contains asp.dll

                Dim aspLoaded As Boolean = False

                Dim diagProcess As System.Diagnostics.Process = System.Diagnostics.Process.GetProcessById(process.ProcessID)

                Dim diagModule As System.Diagnostics.ProcessModule

                For Each diagModule In diagProcess.Modules

                    Dim moduleName As String = System.IO.Path.GetFileName(diagModule.FileName).ToLowerInvariant()

                    If moduleName = "asp.dll" Then

                        aspLoaded = True

                        Exit For

                    End If

                Next



                'If the process contains asp.dll, attach to it

                If aspLoaded Then

                    process.Detach(False)

                    processFound = True

                End If

            Next



            If Not processFound Then

                MsgBox("Could not find this IIS process. Hit a web page containing classic ASP script so that the process will start.")

            End If



        Catch ex As System.Exception

            MsgBox(ex.Message)

        End Try

    End Sub
Reopen question.