c# - HangFire“无法访问已处置的对象。对象名称:'SqlDelegatedTransaction'”
问题描述
在 Visual Studio Mac 中寻找有关 HangFire 的帮助。”这是一个在 Windows / IIS 上运行的 WebAPI 项目。
在启动过程中,HangFire 被初始化。一旦发生这种情况,我们会尝试设置一个经常性的工作。当连接到 Windows 上的 SQL Server 2014 或 Linux 上的 SQL Server 2019 CTP 时,这会引发异常。
{System.Transactions.TransactionAbortedException: Transaction failed ---> System.ObjectDisposedException: Cannot access a disposed object. Object name: 'SqlDelegatedTransaction'. at System.Data.SqlClient.SqlDelegatedTransaction.GetValidConnection () [0x0000a]…}
连接到 Azure SQL 时,它返回
{System.NotImplementedException: The method or operation is not implemented. at System.Transactions.Transaction.EnlistPromotableSinglePhase (System.Transactions.IPromotableSinglePhaseNotification promotableSinglePhaseNotification, System.Guid promoterType)
尝试了 HangFire 1.6.8(适用于 Windows)、1.6.14 和 1.6.21。
调用BackgroundJob.Enqueue
或 时抛出错误RecurringJob.AddOrUpdate
。
为了简化这一点,我实现了一个简单的函数而不是我们的,这也失败了。
例如
BackgroundJob.Enqueue(() => Console.Write("Enqueue"));
任何帮助,将不胜感激!
解决方案
我找到了解决此问题的方法...我必须下载 HangFire 的源代码,将项目添加为引用并将 HangFire.SQLServer 项目设置为在没有“NETFULL”符号的情况下进行编译。
推荐阅读
- java - 如何使用 ImageView 而不是菜单项制作底部导航栏?
- java - 为什么 Spring boot 不接受我的 Axios POST 请求?
- distributed - 我可以将文件块存储在 IPFS 网络中的不同系统中吗?
- sql - 开始在具有非顺序 GUID 的表中添加顺序 GUID 是否存在性能问题
- ruby-on-rails - 如何打印rails应用程序中每个条目的待处理任务计数
- python - 将 numpy 数组传递给 opencv 函数 inputarray 导致数组更改
- python - 如何在可能有一些失真的网格中订购 cv2 轮廓?
- mysql - 如何计算每个用户mysql的timediff
- angular - Angular 9 - 存储的值永远不应该是 NO_CHANGE
- java - 导出时间步以在 Java 中以 x 轴显示