MSMQ Send Problem in ASP.NET

P

Pete Loveall

I have a server application that monitors a private local queue for
messages. The message sent to it has a label and a response queue defined.
It works correctly when the queue is accessed via another program.

However, when I attempt to Send a message from an ASP.NET VB page, I get
"One or more of the passed properties are invalid." I have tried different
combinations of the non-transactional Send() with no success. My
Windows\Temp directory has open access (did this based on another posted
response which took care of the xml formatter loading a temporary dll) but I
cannot get past this message.

If this is a security issue, I need to know how to allow this page send
access as this page must be available to all (no login). It appears that
the queue currently has send access for anonymous login according to the
MSMQ console.

I am posting this on two groups as I do not know which area this really
falls into.

Thanks in advance.

Pete Loveall
AME Corp.
 
Y

Yoel Arnon

Hi Pete,
Can you post the piece of code that fails on ASP.NET? It may be a security
problem with the queue, with Active Directory (depending how you set the
target / response queue) or an unrelated problem. the code would help
here...

All the best,
Yoel Arnon
www.msmq.biz
 
P

Pete Loveall

The basic code is:

Dim mq As MessageQueue = New MessageQueue(".\Private$\myQueue")
mq.DefaultPropertiesToSend.HashAlgorithm = HashAlgorithm.None
mq.DefaultPropertiesToSend.EncryptionAlgorithm = EncryptionAlgorithm.None
If Not MessageQueue.Exists(".\Private$\" & Session.SessionID) Then
MessageQueue.Create(".\Private$\" & Session.SessionID)
Dim respq As MessageQueue = New MessageQueue(".\Private$\" &
Session.SessionID)
respq.MessageReadPropertyFilter.AdministrationQueue = False
respq.MessageReadPropertyFilter.ArrivedTime = False
respq.MessageReadPropertyFilter.Body = False
respq.MessageReadPropertyFilter.CorrelationId = False
respq.MessageReadPropertyFilter.Id = False
respq.MessageReadPropertyFilter.Label = True
respq.MessageReadPropertyFilter.ResponseQueue = False
respq.MessageReadPropertyFilter.SentTime = False
mq.DefaultPropertiesToSend.ResponseQueue = respq
mq.Send(Nothing, "Label Text")
Dim msg As Message = respq.Receive()

I am using only the message label to exchange information. I have also
tried mq.Send("Msg Text") to try using the message body but I get the same
error. It is the Send that is failing. This is the full error message and
stack trace:

Exception Details: System.Messaging.MessageQueueException: One or more of
the passed properties are invalid.

[MessageQueueException (0x80004005): One or more of the passed properties
are invalid.]
System.Messaging.MessageQueue.SendInternal(Object obj,
MessageQueueTransaction internalTransaction, MessageQueueTransactionType
transactionType) +415
System.Messaging.MessageQueue.Send(Object obj, String label,
MessageQueueTransaction transaction, MessageQueueTransactionType
transactionType) +164
System.Messaging.MessageQueue.Send(Object obj, String label) +13
myWeb.testpage.Page_Load(Object sender, EventArgs e) in C:\Hidden for
security reasons\testpage.aspx.vb:77
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750

"Everyone" does have send capabilities on that queue.

Pete Loveall
 
P

Pete Loveall

It appears that either
mq.DefaultPropertiesToSend.HashAlgorithm = HashAlgorithm.None
or
mq.DefaultPropertiesToSend.EncryptionAlgorithm = EncryptionAlgorithm.None
are not allowed in ASP.NET. Commenting these two lines out allowed the
application to work.

Thanks for the help.

Pete Loveall
 
Y

Yoel Arnon

Hi Pete,
Actually the problem was mq.DefaultPropertiesToSend.EncryptionAlgorithm =
EncryptionAlgorithm.None . EncryptionAlgorithm can only be set to RC2 or RC4
(I guess the MSDN documentation -
http://msdn.microsoft.com/library/e...gencryptionalgorithmclasstopic.asp?frame=true
- is misleading on this point).

In order to tell MSMQ to send plain (unencrypted) messages, one shoud set
UseEncryption to false (or simply leave it as is - this is the default).
EncryptionAlgorithm just sets the algorithm used IF UseEncryption is true.

Are you sure th code worked outside of ASP.NET?

All the best,
Yoel Arnon
www.msmq.biz
 
P

Pete Loveall

Yes, it definitely worked outside of ASP.NET. Must be some extra checking
in the ASP.NET code.

Thanks.

Pete Loveall
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top