473,581 Members | 2,783 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

NullRefExceptio n in windows service


Hello

I get the following error when i trying to run a function from
OnStart() in my win-service:
"Object Reference not set to an instance of an object" and the
stacktrace only gives me the function name (setEvents), nothing
else...

protected override void Onstart(string [] args)
{
init_timers();
init_object_lis t();
setEvents(true) ; //the stacktrace tells me that this function
generated the exception
}

the function also gets called every time a timer elapses with the exact
same error. I have tried writing to the system logg in the function to
see how far down the function the service gets before the exception
gets thrown, but it seems it stoppes instantly (first row) and the only
thing that happenes there is a declaration of a string variable. string
foo = "stringval" ;
--
lajo_79
------------------------------------------------------------------------
lajo_79's Profile: http://www.highdots.com/forums/m918
View this thread: http://www.highdots.com/forums/t3018668

Nov 17 '05 #1
4 1105

my guesses are that the exception gets thrown when the function gets
called...
--
lajo_79
------------------------------------------------------------------------
lajo_79's Profile: http://www.highdots.com/forums/m918
View this thread: http://www.highdots.com/forums/t3018668

Nov 17 '05 #2
hi,

Put the solution in debug mode, install the windows service and make sure
it does contains the .pdb file, then in the stacktrace you will see the
line number where the exception occured.

You are using a variable without proper initialization,

If you say that this happen also in a timer event, why don't you put an
breakpoint in the method and the first time the timer's event is fired you
will see why it fails.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"lajo_79" <la************ @no-mx.forums.yourd omain.com.au> wrote in message
news:la******** ****@no-mx.forums.yourd omain.com.au...

Hello

I get the following error when i trying to run a function from
OnStart() in my win-service:
"Object Reference not set to an instance of an object" and the
stacktrace only gives me the function name (setEvents), nothing
else...

protected override void Onstart(string [] args)
{
init_timers();
init_object_lis t();
setEvents(true) ; //the stacktrace tells me that this function
generated the exception
}

the function also gets called every time a timer elapses with the exact
same error. I have tried writing to the system logg in the function to
see how far down the function the service gets before the exception
gets thrown, but it seems it stoppes instantly (first row) and the only
thing that happenes there is a declaration of a string variable. string
foo = "stringval" ;
--
lajo_79
------------------------------------------------------------------------
lajo_79's Profile: http://www.highdots.com/forums/m918
View this thread: http://www.highdots.com/forums/t3018668

Nov 17 '05 #3

the pdb file wasn´t in the setup solution i am using... now its
included and the row number was found!! thank you.. still remains to
evalute the problem but now i know on which line
--
lajo_79
------------------------------------------------------------------------
lajo_79's Profile: http://www.highdots.com/forums/m918
View this thread: http://www.highdots.com/forums/t3018668

Nov 17 '05 #4
Hi,

Good to ear, you do know the problem though, in that line you are using a
variable which was not assigned before ( or is assigned to null for that
matter)

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"lajo_79" <la************ @no-mx.forums.yourd omain.com.au> wrote in message
news:la******** ****@no-mx.forums.yourd omain.com.au...

the pdb file wasn´t in the setup solution i am using... now its
included and the row number was found!! thank you.. still remains to
evalute the problem but now i know on which line
--
lajo_79
------------------------------------------------------------------------
lajo_79's Profile: http://www.highdots.com/forums/m918
View this thread: http://www.highdots.com/forums/t3018668

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
2250
by: Michael Riggio | last post by:
Is there a way to have a windows service instantiate a class that is a web service, which will then be accessible to clients via HTTP? Thanks, -Mike
1
5673
by: Artur Kowalski | last post by:
I have a NotifyIcon in my Windows Service project and I am trying to add a ContextMenu to this NotifyIcon or use some of the mouse events. Everything isn't working. I think so base class of the service System.ServiceProcess.ServiceBase don't catchWindows messages like mouse or timer messages. Any Idea? Thanks,
3
5127
by: belgiozen | last post by:
Hi, I have a working windows service,it is looking for files on the disk and when some of the files are cupdated it calls an executable. But it takes a lot of time(about 10 minutes) to run the executable.So while that executable is running,if I try to stop the windows service while the executable(MYPROGRAM.EXE) is running,it will wait for a...
9
7247
by: SP | last post by:
Hi All, I wrote a windows service which is supposed to stop after specified amount of time. I am calling OnStop() after specified time. OnStop() methods executed but I dont see the service stopping. Please advise how to stop the service. Thanks, SP
1
3442
by: Scott Davies | last post by:
Hi, I'm looking for some help on a small program that I'm trying to develop in VB.NET. I'm having trouble getting the code that I've written to work, can anyone shed some light as to where I'm going wrong. The program has been written to do the following tasks: - Select remote server - Select from two specific services
0
3922
by: Scott Davies | last post by:
Hi, I'm looking for some help on a small program that I'm trying to develop in VB.NET. The program I'm trying to develop needs to be able to do the following: - Select remote server - Select from two specific services - Check the status of the server
2
6883
by: deko | last post by:
When to use a privileged user thread rather than a windows service? That's the question raised in a previous post . It was suggested that if the service needs to interact with a WinForms app (which is the UI used to adjust the actions taken by, and the schedule of the service), then a privileged user thread should be used in the UI - no...
4
4172
by: tshad | last post by:
What would be a good way to check programmatically whether a service was running? We have a service that dies periodically and I need to check to see if this service is running. I know how to check to see if the status is in stopped or running mode. But that doesn't tell me if it is actually running. I need to know this so that if it...
5
3291
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name? Why do I need to set a property within my code to the service name? Are all these required or am I just doing this for consistency purposes?
0
7876
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7804
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8180
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3809
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3832
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2307
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1409
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1144
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.