SQL Service Broker奇怪的问题与权限

时间:2014-04-25 22:59:25

标签: c# sql sql-server service-broker

我在使用SQL服务代理(在SQL Server 2012中)和C#中的SqlDependency时遇到了问题。情况是数据库机器最初与数据库一起部署,用于访问数据库的安全组是db_owner角色的成员,稍后我使用更新脚本部署它,添加更多表,存储过程和作业等等。应用程序服务器我推出了新的构建版本,其中包含使用SqlDependency获取通知的更改。当应用程序启动时,我得到以下异常

  

System.Data.SqlClient.SqlException(0x80131904):类型为service的实体不能由角色,组或映射到证书或非对称密钥的主体拥有...无效的对象名称'SqlQueryNotificationService-36f1b73f-3477 -4b10-ad67-985e1092afff'.....服务器堆栈跟踪:..在System.Data.SqlClient.SqlConnection.OnError(SqlException异常,布尔breakConnection,操作1 wrapCloseInAction).. at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose).. at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady).. at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString).. at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds).. at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource 1完成,Int32超时,任务和任务,Boolean asyncWrite)..在System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1完成,String methodName,Boolean sendToPipe,Int32超时,布尔asyncWrite)..在System.Data.SqlClient.SqlCommand.ExecuteNonQuery().. at SqlDependencyProcessDispatcher.SqlConnectionContainer.CreateQueueAndService(Boolean restart)..在SqlDependencyProcessDispatcher.SqlConnectionContainer..ctor(SqlConnectionContainerHashHelper hashHelper,String appDomainKey,Boolean useDefaults).. at SqlDependencyProcessDispatcher.Start(String c onnectionString,String&服务器,DbConnectionPoolIdentity&身份,字符串&用户,字符串&数据库,字符串& queueService,String appDomainKey,SqlDependencyPerAppDomainDispatcher dispatcher,Boolean& errorOccurred,Boolean& appDomainStart,Boolean useDefaults).. at SqlDependencyProcessDispatcher.StartWithDefault(String connectionString,String& server,DbConnectionPoolIdentity& identity,String& user,String& database,String& service,String appDomainKey,SqlDependencyPerAppDomainDispatcher dispatcher,Boolean& errorOccurred,Boolean& appDomainStart)。 。在System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md,Object [] args,Object server,Object []& outArgs).. at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg) ....在[0]处重新抛出异常:..在System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)..在System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData ,Int32类型)..在SqlDependencyProcessDispatcher.StartWithDefault(String connectionString,String& server,DbConnectionPoolIdentity& identity,String& user,String&放大器;数据库,字符串& service,String appDomainKey,SqlDependencyPerAppDomainDispatcher dispatcher,Boolean& errorOccurred,Boolean& appDomainStart)..在System.Data.SqlClient.SqlDependency.Start(String connectionString,String queue,Boolean useDefaults)..

但是,当我登录到数据库服务器并删除该安全组的db_owner角色并将其添加回来时(使用SQL Management Studio UI)一切似乎都有效,应用程序的异常消失了,它现在可以创建服务与SQL服务器上的队列(使用sp_addrolemember和ALTER ROLE添加和删除角色不能解决只能通过UI工作的问题)。我不确定问题的根本原因是什么,我想解决问题而不是解决问题。

0 个答案:

没有答案