Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

newbie - web services project where to put Sub main? 1

Status
Not open for further replies.

Big1934

Programmer
Jul 1, 2009
33
0
0
US
On my build I get the error that it could not find sub main.
I was using an online example to get my code this far.: Business logic removed

Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Imports System.Text.RegularExpressions
Imports System.Configuration
Imports System.Collections.Specialized.NameValueCollection

Public Class fileWatchService : Inherits System.ServiceProcess.ServiceBase


Protected Overrides Sub OnStart(ByVal args() As String)
' Add code here to start your service. This method should set things
' in motion so your service can do its work.
Me.FileWatcher.EnableRaisingEvents = True 'THIS is what turns ON the FILEWATCHER
Me.FileWatcher.Filter = "*.pdf"

End Sub

Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop your service.
Me.FileWatcher.EnableRaisingEvents = False 'THIS is what turns OFF the FILEWATCHER
End Sub

Private Sub FileWatcher_Changed(ByVal sender As System.Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileWatcher.Changed
Try
Dim _sDir As String = ConfigurationSettings.AppSettings("WatchDirectory") ' currently C:\TEMP ,needs to be \\Dc1\EFiles in app.conf
Dim _dDir As New DirectoryInfo(_sDir)...
...rest of Business logic removed.

connection.Close()
Catch ex As Exception

End Try
End Sub

End Class
 
You're writing a Windows Service, not a Web Service. Windows Services have OnStart/OnStop. Anyways, Right-click your project in the solution explorer and select Properties. Under the Application tab, change "Startup Object" from Sub Main to your service class.
 
Thanks.it is set on new projects to be the start up on default, guess I put it on sub main click'n around trying to get a feel for the environment, when i said newbie i meant super newbie.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top