SQLDependency挂一段时间后失效。

FainSheeg FainSheeg 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
如题,使用SQLDependency来监测数据库改变,代码已实现,功能正常。
但是有时候挂一段时间后就失效了,不能再随数据库改变而触发OnChange事件,这个“一段时间”有长有短。从有效到无效的过程,程序不会有任何错误提示,就只是不能触发了。
于是查看了一下SQLServer日志,发现有重复的两个错误:
The query notification dialog on conversation handle '{B95987F3-A925-E811-BF09-F8BC12926344}.
' closed due to the following error: '
<?xml version="1.0"?>
<Error xmlns="http://schemas.microsoft.com/SQL/ServiceBroker/Error">
<Code>-8490</Code>
<Description>Cannot find the remote service 'SqlQueryNotificationService-133aba61-6b63-4808-964f-aded417c518d' because it does not exist.</Description>
</Error>'

The query notification dialog on conversation handle '{0C0CFA69-7B23-E811-A9B6-F8BC12926344}.
' closed due to the following error: '
<?xml version="1.0"?>
<Error xmlns="http://schemas.microsoft.com/SQL/ServiceBroker/Error">
<Code>-8470</Code>
<Description>Remote service has been dropped.</Description>
</Error>'.

还有一个出现过一次的错误:
Service Broker needs to access the master key in the database 'PrintedRecords'. Error code:26. The master key has to exist and the service master key encryption is required.

不了解SQLDependency类的内部实现,所以不知道原因。不知道有没有可能是网络不稳定导致的数据库连接断开导致的?如果是的话有没有好的解决办法?
...全文

相关推荐

评论 7
收藏 已收藏
分享
返回顶部
FainSheeg
C# 111,129 成员 642,539 内容