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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Interesting NullReferenceException Error - Windows Service

Status
Not open for further replies.

croag

MIS
Nov 8, 2001
49
0
0
US
Hello,

I'm wiritng a service, and when attempting to start the service (after installing using installutil) I receive this is the Application Log:

Service cannot be started. System.NullReferenceException: Object reference not set to an instance of an object.
at PxpParser.PxpParser.StartWatch() in C:\Visual Studio Projects\PxpParser\PxpParser.vb:line 135
at PxpParser.PxpParser.OnStart(String[] args) in C:\Visual Studio Projects\PxpParser\PxpParser.vb:line 363
at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)



Funny thing is my Line 135 reads like this:
watcher.Path = dump

AND dump is defined earlier (outside of the funciton that line 135 is in) on line 29 as:
Public dump As String = "c:\cytodata\dump"


AND My line 363 is just the StartWatch() in:
Protected Overrides Sub OnStart(ByVal args() As String)
StartWatch()
End Sub


So What the HECK is going on! I don't get it...This service should be starting up and I am pulling my hair out. I need some direction please. Thanks in advance!!

-- croag
 
what is watcher? Maybe that has not been instantiated?

Mark [openup]
 
Whoops...I'm sorry for not listing that one.

Watcher is actually my FileSystemWatcher

I define it like this

Public watcher As FileSystemWatcher
 
Do all objects need to instansiated?
 
would public watch as new FileSystemWatcher be better?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top