By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,866 Members | 1,660 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,866 IT Pros & Developers. It's quick & easy.

Windows service NullReferenceException

P: n/a
hi,

I have a windows service written in VB.Net and framework 2.0. It is a
multithread service and it is using threadpool to manage threads.

Recently I have started getting NullReferenceException and after that
windows service crashes.

System.Transactions Critical: 0 : <TraceRecord
xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord"
Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled
exception</Description><AppDomain>PublishingServiceTestApp.vs host.exe</AppDomain><Exception><ExceptionType>System.NullRef erenceException,
mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Object reference not
set to an instance of an object.</Message><StackTrace at
System.Threading.Overlapped.Free(NativeOverlapped* nativeOverlappedPtr)
at System.Net.Sockets.OverlappedCache.InternalFree()
at
System.Net.Sockets.OverlappedCache.InterlockedFree (OverlappedCache&amp;amp;
overlappedCache)
at
System.Net.Sockets.BaseOverlappedAsyncResult.Force ReleaseUnmanagedStructures()
at System.Net.Sockets.BaseOverlappedAsyncResult.Clean up()
at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
at System.Net.ContextAwareResult.CompleteCallback(Obj ect state)
at System.Threading.ExecutionContext.runTryCode(Objec t userData)
at
System.Runtime.CompilerServices.RuntimeHelpers.Exe cuteCodeWithGuaranteedCleanup(TryCode
code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(Exec utionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
at System.Net.ContextAwareResult.Complete(IntPtr userToken)
at System.Net.LazyAsyncResult.ProtectedInvokeCallback (Object result,
IntPtr userToken)
at
System.Net.Sockets.BaseOverlappedAsyncResult.Compl etionPortCallback(UInt32
errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at
System.Threading._IOCompletionCallback.PerformIOCo mpletionCallback(UInt32
errorCode, UInt32 numBytes, NativeOverlapped*
pOVERLAP)</StackTrace><ExceptionString>System.NullReferenceEx ception: Object
reference not set to an instance of an object.
at System.Threading.Overlapped.Free(NativeOverlapped*
nativeOverlappedPtr)
at System.Net.Sockets.OverlappedCache.InternalFree()
at
System.Net.Sockets.OverlappedCache.InterlockedFree (OverlappedCache&amp;amp;
overlappedCache)
at
System.Net.Sockets.BaseOverlappedAsyncResult.Force ReleaseUnmanagedStructures()
at System.Net.Sockets.BaseOverlappedAsyncResult.Clean up()
at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
at System.Net.ContextAwareResult.CompleteCallback(Obj ect state)
at System.Threading.ExecutionContext.runTryCode(Objec t userData)
at
System.Runtime.CompilerServices.RuntimeHelpers.Exe cuteCodeWithGuaranteedCleanup(TryCode
code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(Exec utionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
at System.Net.ContextAwareResult.Complete(IntPtr userToken)
at System.Net.LazyAsyncResult.ProtectedInvokeCallback (Object result,
IntPtr userToken)
at
System.Net.Sockets.BaseOverlappedAsyncResult.Compl etionPortCallback(UInt32
errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at
System.Threading._IOCompletionCallback.PerformIOCo mpletionCallback(UInt32
errorCode, UInt32 numBytes, NativeOverlapped*
pOVERLAP)</ExceptionString></Exception></TraceRecord>

Can anyone help me to identify the problem?
May 22 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"mdhaman" <12**@1234.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
hi,

I have a windows service written in VB.Net and framework 2.0. It is a
multithread service and it is using threadpool to manage threads.

Recently I have started getting NullReferenceException and after that
windows service crashes.
Can anyone help me to identify the problem?
The NullReferenceException means a reference to an object has not been
instantiated/set or has been destroyed when the code referencing the object
wanted to use the object.

It could be that the Garbage Collector came along and destroyed the object
at one point, which could be a problem if the object is only instantiated
one time, or somehow, the code has taken a path to not instantiate the
object, if you are manually destroying objects.

IMHO, the best way you're going to be able to pin point what area of the
program it's going down in is doing Try/Catches in your routines and on the
Catch, dump the Ex.Message and ex.Stacktrace to the Eventlog or to a text
file if you like, which the Stacktrace will at least give you the name of
the routine it's going down in.

Then you can look at the objects in that area and make a determination as to
what object could be setting at a Null value when the code wants to use the
object.





May 23 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.