调用[Autocomplete]修饰的方法时,“值不能为null”

时间:2013-09-04 07:29:44

标签: c# autocomplete transactions argumentnullexception servicedcomponent

我有一个Windows Forms应用程序(.NET 3.5),它使用ClickOnce技术部署,大约有50-100个并发用户使用。它们都针对外部托管的相同MS SQL数据库(SQL SERVER 2008 R2)。

应用程序本身使用“wrapper”类来执行数据库查询。此类派生自 ServicedComponent ,并使用 [AutoComplete] 属性修饰其方法。以下是一个例子:

[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);
    }
}

大多数情况下,这种方法就像魅力一样。但是,当调用此方法时,会发生异常后的一天(当然,对于这个确切的问题,有类似的方法):

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). 

正如您所见,异常中提到了 CTxGreenfee374Processor 类中的 SaveSeason 方法。据我所知,这是我写过的最后一段代码。

我唯一的线索是该例外与 [AutoComplete] 属性和/或派生的 ServicedComponent 类有关。这个结论是基于我检查了无效的输入参数,并且在异常之前没有执行方法内部的代码。我假设 ServicedComponent 类和 [AutoComplete] 属性在方法块执行之前执行了一些逻辑。

我在调试时没有成功重新创建此异常,因为此异常的后续发生。所以我不得不依赖生产应用程序中的日志。

如果有人对这个问题有所了解,那将非常感激!

0 个答案:

没有答案