Saturday, April 25, 2009

MSMQ in work group environment

Recently I realized that my application that was working fine on domain machine wont work on work group environment. On analyzing I found that it was because of the MSMQ that was being used by WCF to communicate. I have used Public queues which are not allowed in work group. I just changed my code to create private queue and it started working fine. I was surprised to know that the trick of making a queue public/private was in its name.
Name = machineName\QueueName - Public Queue
Name = machineName\Private$\QueueName - Public Queue

Unlike Public queue, Private queues can not be created on the remote machine.

I thought all was done and my application will start running fine with this change. However, one more hurdle was waiting its turn. The ServiceHost instantiation reported error
There was an error opening the queue. Ensure that MSMQ is installed and running, the queue exists and has proper authorization to be read from. The inner exception may contain additional information.
The Inner exception read:
An error occurred while opening the queue:The queue does not exist or you do not have sufficient permissions to perform the operation. (-1072824317, 0xc00e0003). The message cannot be sent or received from the queue. Ensure that MSMQ is installed and running. Also ensure that the queue is available to open with the required access mode and authorization.

Prima-facie it looked like a permission/rights issue. I googled the error message and was suggested to try various options like creating the user with same id and password on both the machine and giving full control of the queue to the anonymous user. However, non of them worked.

Finally a trail worked. I just changed URI end point from

net.msmq://machineName/QueueName

to

net.msmq://machineName/private/QueueName

Tuesday, April 21, 2009

Some very good articles related to MSMQ

Unable to create Public/Private queues on remote machine

1) Following is used to create a public queue programmatically
System.Messaging.MessageQueue.Create(@"myMachine\MyQueue");
You can use an overload of the Create method to indicate that you want to create a transactional queue. You can also use a period ( . ) in the path to indicate the local machine.

However, when I tried to create the public queue on the remote machine I got the following exception:

An unhandled exception of type 'System.Messaging.MessageQueueException' occurred in System.Messaging.dll
Additional information: External component has thrown an exception.

I fixed this by assigning 'create queue' rights for the user (through which my application was creating the queue) on 'Messaging Queue' of the target machine.

2) Following is used to create a private queue programmatically System.Messaging.MessageQueue.Create(@"myMachine\Private$\MyQueue");

Private queues can just not be created on remote machine.

Thursday, April 16, 2009

.NET Framework 2.0 SP2 related issue

I installed .NET Framework 2.0 SP2 on my machine and found that my C# ASP.NET application that was running fine started reporting 'Page not found' error. When I clicked 'Submit' button on the login page the application would redirect to 404. To make sure the problem originated because of the SP2, I removed it and found that my application was back to normal. On research I found that Microsoft has released updates to .NET Framework 2.0 SP2. However, that too didnt solved my problem. Ultimately I found that the issue was in the form tag of the login page. The action property was set as “ ”. This was resulting in a page not found error when the page was posted back. .NET Framework 2.0 SP2 didnt liked action=" ". However it is ok if you write action="" or action="#" or action="login.aspx" or remove the action property.