Resolving reference to non-shared member requires an object reference

Posted on 2006-05-01
Last Modified: 2008-02-20
I understand this compile error message in the context of simple windows objects but I am confused how to resolve in this case:

I've recently learned I cannot debug classic ASP within Visual Studio 2005 (none of my breakpoints are reached).

So, according to:        

...I am trying to use the add-in wizard to implement the macro documented in item 2 in the weblog reference above. Here is the key snippet from the code I am trying to use:

Imports System
Imports Microsoft.VisualStudio.CommandBars
Imports Extensibility
Imports EnvDTE
Imports EnvDTE80

Public Class Connect
    Implements IDTExtensibility2
    Implements IDTCommandTarget
    Dim _applicationObject As DTE2
    Dim _addInInstance As AddIn
    Public Sub Exec(ByVal commandName As String, ByVal executeOption As vsCommandExecOption, ByRef varIn As Object, ByRef varOut As Object, ByRef handled As Boolean) Implements IDTCommandTarget.Exec
        handled = False
        If executeOption = vsCommandExecOption.vsCommandExecOptionDoDefault Then
            If commandName = "debugClassicASP.Connect.debugClassicASP" Then
                handled = True
                Exit Sub
            End If
        End If
      End Sub
    Sub ClassicASPAttach()
            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                              '<---- ERROR: reference to a non-shared member requires an object reference
                '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
                'If the process contains asp.dll, attach to it
                If aspLoaded Then
                    processFound = True
                End If
            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
        End Try

    End Sub
End Class

Question by:jjamjatra
    LVL 96

    Expert Comment

    by:Bob Learned
    There is the Tools | Attach to Process command to connect the debugger to the worker process.


    Author Comment

    Please read the weblog on MSDN if you would like to help me.

    ASP cannot be debugged via Visual Studio 2005. I have tried and the breakpoints do not get stopped on. Attempting to attach to the worker process also does not work (buttons remain disabled). According to the MSDN entry this is by design.

    Therefore, my question is about the compile time problem I am getting with the "workaround" discussed in the same weblog. Can anyone point out how to resolve this problem with the DTE reference that is required?
    LVL 96

    Expert Comment

    by:Bob Learned



    Author Comment

    Thank you. That solved the problem. What do I have to do now to close this case?
    LVL 96

    Accepted Solution

    There should be an <Accept> button.   Click it, and give me an "A" grade.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    Article by: Kraeven
    Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now