Hello,
I have finished a small Server and Client Solution using MSMQ for sending text messages between Server and Client.
Works perfect in my Domain.
Now I got the bad news. I must get it working without a domain (internet is available).
My solution is quite simple until now:
Checking and adding the queue:
public void check_Queue(string queueName)
{
if (!MessageQueue.Exists(".\\" + queueName))
{
MessageQueue queue;
try
{
queue = MessageQueue.Create(".\\" + queueName, false);
queue.QueueName = queueName;
queue.Label = queueName;
AccessControlList list = new AccessControlList();
Trustee tr;
if ((Thread.CurrentThread.CurrentUICulture.ToString().ToUpper() == "DE")
|| (Thread.CurrentThread.CurrentUICulture.ToString().ToUpper() == "DE-DE"))
tr = new Trustee("Jeder");
else
tr = new Trustee("Everyone");
AccessControlEntry entry = new AccessControlEntry(tr, GenericAccessRights.All, StandardAccessRights.All, AccessControlEntryType.Allow);
list.Add(entry);
queue.SetPermissions(list);
}
catch (Exception ex)
{
_log.Log.Error(SiCResourceManager.GetResourceString(SiCResourceManager.SiEStringResource.ErrorMessage) + Environment.NewLine + ex.Message.ToString());
}
}
}
Sending a message:
public void SendMessage(string fullClientName, string msgText)
{
try
{
queue.Send(msgText);
return;
}
catch (Exception ex)
{
_log.Log.Error(SiCResourceManager.GetResourceString(SiCResourceManager.SiEStringResource.ErrorMessage) + Environment.NewLine + ex.Message.ToString());
}
}
Receiving a message:
public string ReceiveMessage(string queueName)
{
queue.Formatter = new XmlMessageFormatter(new Type[] { typeof(string) });
string msgText = "";
try
{
TimeSpan maxTime = new TimeSpan(SiCGlobals.receiveTimeout);
Message myMessage = queue.Receive(maxTime);
msgText = (string)myMessage.Body;
}
catch (MessageQueueException ex)
{
}
catch (InvalidOperationException ex)
{
}
catch (Exception ex)
{
}
return msgText;
}
It seems I already get a problem when I try to check / add my queue and I am not in a domain.
Anybody experienced with that and could please give me some hints?
Thanks a lot
Eric
PS:
I now startet my server application on a PC which is not in the domain.
Checking the Queue seems to work.
But then I get an exception here "Workstation installation does not support..."
when starting it in the domain it worked.
<pre> lang="cs">queue.ReceiveCompleted += new
ReceiveCompletedEventHandler(QueueReceiveCompleted);</pre>
PPS: I changed all the queues to be private queues. Adding the queue works,
and the Receive..Handler does not throw an exception anymore.
But (Firewall is off) the Server does not take any messages.
When sending a message with the Client I now use:
MessageQueue clientQueue = new MessageQueue(fullName + @"\Private$\" + queueName);
I get an "Invalid queue path name". fullName is an IP right now.
When I remove that Private$\\ then path is not invalid anymore, but it does not find that queue (because it is provate now). Any suggestion how to send a message to that private queue? Thanks!