简体   繁体   中英

HangFire "Cannot access a disposed object. Object name: 'SqlDelegatedTransaction'"

Looking for some help with HangFire in Visual Studio Mac." It is a WebAPI project that works on Windows / IIS.

During startup, HangFire is initialized. Once this happens, we try to set up a recurring job. This is throwing an exception when connected to SQL Server 2014 on Windows OR SQL Server 2019 CTP on Linux.

{System.Transactions.TransactionAbortedException: Transaction failed ---> System.ObjectDisposedException: Cannot access a disposed object. Object name: 'SqlDelegatedTransaction'. at System.Data.SqlClient.SqlDelegatedTransaction.GetValidConnection () [0x0000a]…}

When connecting to Azure SQL, it returns {System.NotImplementedException: The method or operation is not implemented. at System.Transactions.Transaction.EnlistPromotableSinglePhase (System.Transactions.IPromotableSinglePhaseNotification promotableSinglePhaseNotification, System.Guid promoterType) {System.NotImplementedException: The method or operation is not implemented. at System.Transactions.Transaction.EnlistPromotableSinglePhase (System.Transactions.IPromotableSinglePhaseNotification promotableSinglePhaseNotification, System.Guid promoterType)

Tried HangFire 1.6.8 (works on Windows), 1.6.14 and 1.6.21.

Error is thrown when calling BackgroundJob.Enqueue or RecurringJob.AddOrUpdate .

To simplify this, I implemented as simple function instead of ours, which also fails.

eg BackgroundJob.Enqueue(() => Console.Write("Enqueue"));

Any help would be appreciated!

I found a way to resolve this... I had to download the source for HangFire, add the projects as references and set the HangFire.SQLServer Project to compile without the "NETFULL" Symbol.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM