My Executable file (C# WPF Solution) is not running properly when being called by MSMQ Trigger.
I am sending a notification mesasge to the queue (named sometestname): I have a class called MyNotification that includes this static method:
public class MyNotification {
public static void SendNotification(String destination,String msg){
string s = @".\Private$\sometestname" + "-" + destination;
if(!MessageQueue.Exists(s))
MessageQueue.Create(s,false);
MessageQueue q = new MessageQueue(s);
Message msg = new Message();
msg.Body = msg;
q.Send(message);}
}
a WPF Solution that uses this class:
void ButtonBase_OnClick(object sender,RoutedEventArgs s){ MyNotification.SendNotification("user1","testing message");}
the .exe that will be fired from trigger (when the message is received) :
Public MainWindow(){
String queueName = @".\Private\sometestname-user1";
MessageQueue msgq = new MessageQueue(queueName,false);
try{
msgq.Purge();
}
catch(MessageQueueException e){
string filename = @"C:\Users\user1\Desktop\error.txt";
File.Create(filename);
}
}
Note that:the message is arriving to the queue,and the executable file is showed running in the background,but it catches an error. When the executable file is executed manually,it executes nromally without any errors(i.e. no file is created). But When its fired from the MSMQ Trigger(Includes a rule the invoke standalone executable when message arrives),it catches an exception(i.e. file is created).