473,473 Members | 1,614 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

NullRefException 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_list();
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 1098

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.yourdomain.com.au> wrote in message
news:la************@no-mx.forums.yourdomain.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_list();
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.yourdomain.com.au> wrote in message
news:la************@no-mx.forums.yourdomain.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
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
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...
3
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...
9
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...
1
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...
0
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 -...
2
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...
4
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...
5
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?...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.