"Value cannot be null" when invoking method decorated with [Autocomplete]

881 views Asked by At

I have a Windows Forms application (.NET 3.5) which is deployed with the ClickOnce-technology and is used by approximately 50-100 concurrent users. They all target the same MS SQL database (SQL SERVER 2008 R2) which is hosted externally.

The application itself uses a "wrapper"-class to perform database queries. This class derives from ServicedComponent and decorates its methods with the [AutoComplete] attribute. Below is an example:

[Serializable]
[Transaction(TransactionOption.Required, Isolation=TransactionIsolationLevel.ReadCommitted)]
public class CTxGreenfee374Processor: ServicedComponent
{
    public CTxGreenfee374Processor() { }

    [AutoComplete]
    internal Season SaveSeason(CallContext callContext, Season season)
    {
        return new PGreenfee374Processor().SaveSeason(callContext, season);
    }
}

Most of the time this approach works like a charm. But numerous times a day following exception occur when this method gets invoked (of course there are similar methods with this exact problem):

System.ArgumentNullException
Value cannot be null.
Server stack trace: 
  at System.Threading.Monitor.Enter(Object obj) 
  at System.Data.ProviderBase.DbConnectionPool.TransactedConnectionPool.TransactionEnded(Transaction transaction, DbConnectionInternal transactedObject) 
  at System.Data.ProviderBase.DbConnectionPool.TransactionEnded(Transaction transaction, DbConnectionInternal transactedObject) 
  at System.Data.ProviderBase.DbConnectionInternal.CleanupConnectionOnTransactionCompletion(Transaction transaction) 
  at System.Data.SqlClient.SqlDelegatedTransaction.SinglePhaseCommit(SinglePhaseEnlistment enlistment) 
  at System.Transactions.TransactionStateDelegatedCommitting.EnterState(InternalTransaction tx) 
  at System.Transactions.TransactionStateDelegated.BeginCommit(InternalTransaction tx, Boolean asyncCommit, AsyncCallback asyncCallback, Object asyncState) 
  at System.Transactions.CommittableTransaction.Commit() 
  at System.EnterpriseServices.TransactionProxy.Commit(Guid guid) 
  at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) 
  at System.EnterpriseServices.Thunk.Callback.DoCallback(Object otp, IMessage msg, IntPtr ctx, Boolean fIsAutoDone, MemberInfo mb, Boolean bHasGit) 
  at System.EnterpriseServices.ServicedComponentProxy.CrossCtxInvoke(IMessage reqMsg) 
  at System.EnterpriseServices.ServicedComponentProxy.Invoke(IMessage request) 
  at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 
  at GOLFIT.BusinessProcess.Economics.CTxGreenfee374Processor.SaveSeason(CallContext callContext, Season season) 
  at GOLFIT.BusinessProcess.Economics.Greenfee374Processor.SaveSeason(CallContext callContext, Season season) in C:\Projekt\GOLFIT\DEVELOPMENTPROD374\BusinessProcess\GOLFIT.BusinessProcess.Economics\Greenfee374\Greenfee374Processor.cs:line 104 
  at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs) 
  at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs) 
  at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext) 
Exception rethrown at [0]: 
  at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 
  at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 
  at GOLFIT.BusinessProcess.Economics.Greenfee374Processor.SaveSeason(CallContext callContext, Season season)
  at GOLFIT.WinGUI.Economics.FrmPrice374.Save(Boolean refresh). 

As you can see the method SaveSeason in the CTxGreenfee374Processor class is mentioned in the exception. As far as I can see this is the last trace of code that I've written.

My only clue is that the exception has something to do with the [AutoComplete] attribute and/or the derived ServicedComponent class. This conclusion is based on that I've checked for invalid input parameters and that no code inside the method gets executed before the exception. And I assume that both ServicedComponent class and [AutoComplete] attribute performs som kind of logic before the method block executes.

I haven't been successful in recreating this exception when debugging, due to inconsequent occurrences of this exeption. So I've had to depend on logs from the production application.

If anyone got an idea regarding this problem it would be extremely appreciated!

0

There are 0 answers