这是我的服务合同:
<ServiceContract> _
<ServiceKnownType(GetType(String))> _
Public Interface ISecurityMasterChanged
<OperationContract(IsOneWay:=True, Action:="*")> _
Sub ValidateCusipInMessage(ByVal message As MsmqMessage(Of String))
End Interface
这是我的课
Public Class SecurityValidator
Implements ISecurityMasterChanged
<OperationBehavior(TransactionAutoComplete:=False, TransactionScopeRequired:=False)> _
<ServiceKnownType(GetType(String))> _
Public Sub ValidateCusipInMessage(ByVal message As MsmqIntegration.MsmqMessage(Of String)) Implements ISecurityMasterChanged.ValidateCusipInMessage
'...
End Sub
当我尝试使用此代码打开端口时,出现错误
m_ServiceHostQueue = New ServiceHost(Me)
m_ServiceHostQueue.AddServiceEndpoint(GetType(ISecurityMasterChanged), New MsmqIntegrationBinding With {.ExactlyOnce = False}, m_Config("SMChanged Queue").ToString)
m_ServiceHostQueue.Open()
System.InvalidOperationException 发生 Message="合同 'ISecurityMasterChanged' 上的操作 'ValidateCusipInMessage' 配置为 TransactionAutoComplete 设置为 true,TransactionScopeRequired 设置为 false。TransactionAutoComplete 要求 TransactionScopeRequired 设置为 true。" 源="系统.ServiceModel"
这对我来说没有意义,因为如您所见,TransactionAutoComplete 未设置为 true。