Exception: System.NullReferenceException

.NET library for SMPP protocol
Posts: 1
Joined: Wed Oct 03, 2012 1:32 pm

Exception: System.NullReferenceException

Post by canibam » Wed Oct 03, 2012 2:06 pm


there is no any problem when i send several messages using inetlabSmpp dll. The problem is when i try to send a massive message list using the same method in a loop, it couses the application pool to be disabled. when i check the event log, i realized that the error i posted below was been thrown for many times . I would appriciate it if anyone could help me with this problem.



An unhandled exception occurred and the process was terminated.

Process ID: 4620

Exception: System.NullReferenceException

Message: Object reference not set to an instance of an object.

StackTrace: at System.Web.HttpApplication.ThreadContext.Enter(Boolean setImpersonationContext)
at System.Web.HttpApplication.OnThreadEnterPrivate(Boolean setImpersonationContext)
at System.Web.AspNetSynchronizationContext.CallCallbackPossiblyUnderLock(SendOrPostCallback callback, Object state)
at System.Web.AspNetSynchronizationContext.CallCallback(SendOrPostCallback callback, Object state)
at Inetlab.SMPP.Common.SmppClientBase.tXdQoxqOkH()
at Inetlab.SMPP.Common.SmppClientBase.Disconnect()
at Inetlab.SMPP.Common.SmppClientBase.usm16WP60(IAsyncResult )
at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.Run(ExecutionContext 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.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
Site Admin
Posts: 918
Joined: Tue Apr 25, 2006 9:45 am

Re: Exception: System.NullReferenceException

Post by alt » Thu Oct 04, 2012 6:18 pm

Hi canibam,

This could be an exception in evDisconnected event handler.
Or you need to disable ability to run events in main thread where client is created.

Code: Select all

client.RaiseEventsInMainThread = false;
This code above forces client to raise events in the worker thread.
Posts: 1
Joined: Tue Jan 19, 2016 6:56 am

Re: Exception: System.NullReferenceException

Post by evancroby » Tue Jan 19, 2016 6:58 am

Hope this will help you.....NullReferenceException