Results 1 to 2 of 2

Thread: [RESOLVED] Windows Service App: reference to a non shared member requires an object reference

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2010
    Posts
    67

    Resolved [RESOLVED] Windows Service App: reference to a non shared member requires an object reference

    First off let me clarify that this is not a Windows Form application. It is a Windows Service application and this difference is why I cannot get this code to work.

    The part that is giving me the error is: Process.Kill() (which shows: reference to a non shared member requires an object reference)

    Can someone please help me. I'm not sure how to make give it an object reference.


    Code:
    Public Class Service1
        Private Shared timer1 As System.Timers.Timer
        Private Shared timerInterval1 As Integer
        Private Shared timer2 As System.Timers.Timer
        Private Shared timerInterval2 As Integer
    
        Protected Overrides Sub OnStart(ByVal args() As String)
            ' Add code here to start your service. This method should set things
             End Sub
    
        Protected Overrides Sub OnStop()
            ' Add code here to perform any tear-down necessary to stop your service.
        End Sub
    
        Function StopVPN()
            Try
                Dim IKillProc() As Process = Process.GetProcessesByName("openvpn")
    
                For Each Process As Process In IKillProc
    
                Next
                Process.Kill()
            Catch x As Exception
            End Try
            'Return True
        End Function
    End Class

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Aug 2010
    Posts
    67

    Re: Windows Service App: reference to a non shared member requires an object referenc

    Private Shared process As Process

    Adding that seems to do the trick.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width