"System.Messaging.MessageQueueException: The transaction usage is invalid.
at System.Messaging.MessageQueue.SendInternal(Object obj,
MessageQueueTransaction internalTransaction, MessageQueueTransactionType
transactionType)
at System.Messaging.MessageQueue.Send(Object obj, MessageQueueTransaction
transaction)
at QueuePost.QPost.sendTestMessage(String sQue, String strLabel, String
strBody) "
I have tried every usage variation I can think of for
MessageQueueTransaction (including not using it all), to no avail. Any
insights would be greatly appreciated. The code follows:
Public Sub sendTestMessage(ByVal sQue As String, ByVal strLabel As String,
ByVal strBody As String)
Dim oQue As New Messaging.MessageQueue()
Dim oMessage As New Messaging.Message()
oQue.MachineName = "<machinename>"
oQue.QueueName = sQue
Try
If oQue.Transactional Then
Dim objTxn as New MessageQueueTransaction()
objTxn.Begin()
oQue.Send(strLabel, strBody)
objTxn.Commit()
Else
oQue.Send(strLabel, strBody)
strResult = "Succeeded"
End If
Catch e As Messaging.MessageQueueException
strResult += e.Message & e.StackTrace
Finally
lblQueueResult.Text = strResult
End Try
frmQueueConfirmation.Visible = True
End Sub
On the send method, pass the transaction object as the third parameter.
In your code, you're doing a non-transactional send.
Thanks, Doron
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"David Worsham" <dwor...@stewart.com> wrote in message
news:OBwTbWOgCHA.212@tkmsftngp12...
I am using the following and still receiving the error (double-checked the
fact that the queue is public and transactional, too):
If oQue.Transactional Then
Dim objBW As New BinaryWriter(New MemoryStream())
Dim objSR As New StreamReader(strFilePath)
Dim objTxn As New MessageQueueTransaction()
objBW.Write(objSR.ReadToEnd())
oMessage.BodyStream = objBW.BaseStream
oMessage.Label = "Test Message"
oQue.Send(oMessage, objTxn)
objBW.Close()
objSR.Close()
End If
"Doron Juster [MS]" <Dor...@Microsoft.com> wrote in message
news:OK6ZyzPgCHA.2620@tkmsftngp09...
"David Worsham" <dwor...@stewart.com> wrote in message
news:eEXvTfQgCHA.1960@tkmsftngp12...