473,796 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Starting an application using MSMQ from Windows service

Hi,

I have a problem when I try to start an application using MSMQ from a
Windows Service. The application runs on a server. The client send a
message to a public queue created on the server, the server process
the request and return the result to a public queue on the client.
All is working fine if I start my application directly on the server.
But we want to embed the start of the application into a Windows
service. When I install the service that I create for this, I use the
account LocalSystem. On the server, I add the users "SYSTEM" and
"NETWORK SERVICE" with full control on my message queue.

All it seems to be executed correctly, I log many events and
everything is executed without errors. The service start the process
and the process is intiliized correctly. The only problem that I have
is that I never receive messages into my application when it is
started from the Windows service. The message is in the Queue on the
server but the event ReceiveComplete d seems to never be called.

Did someone have any idea why a never receive the message???

Here is the code that I wrote to create the message queue on the
server side:

/////////////////////////////////////////////////////////////////////////

public MessageQueueMan ager()
{
string mesageQueueName =

System.Configur ation.Configura tionSettings.Ap pSettings["MessageQueueNa me"];
//Construct the path of the queue
string queuePath = ".\\mesageQueue Name";

MessageQueue messageQueue;
//Init the message queue
if (MessageQueue.E xists(queuePath ) == true)
{
// Yes, then create an object representing the
queue
messageQueue = new MessageQueue(qu euePath);
}
else
{
// No, create the queue and cache the returned
object
messageQueue = MessageQueue.Cr eate(queuePath) ;
}

// Create an array of types expected in the message
body
Type[] expectedTypes = new Type[] { typeof(string) };

messageQueue.Fo rmatter = new
XmlMessageForma tter(expectedTy pes);

messageQueue.Re ceiveCompleted += new
ReceiveComplete dEventHandler(m essageQueue_Rec eiveCompleted);

//Start the asynchronous receive operation.
IAsyncResult ar = messageQueue.Be ginReceive();
}

static void messageQueue_Re ceiveCompleted( object sender,
ReceiveComplete dEventArgs e)
{
// Cast the state object to MessageQueue
MessageQueue messageQueue = null;

try
{
messageQueue = (MessageQueue)s ender;

...
}
catch (Exception ee)
{
ErrorLogger.Ins tance.LogMessag e(EVENT_SRC,
EventLogEntryTy pe.Error, ee.Message, ee.StackTrace);
}
finally
{
if (messageQueue != null)
{
// Restart the asynchronous receive operation.
messageQueue.Be ginReceive();
}
}

}

/////////////////////////////////////////////////////////////////////////

Thanks
Dominique
Mar 21 '08 #1
0 1691

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1786
by: Glenn | last post by:
I have used this code successfully in a form application. I tried to add the same code in a service and have not been able to get the application to start. I have the service starting with a local account and the Interact with the Desktop is Checked. Windows media player seems to start but then closes almost immediately. I would appreciate any help. Thanks, Glenn
3
10889
by: BizzyTalking | last post by:
Would any kindly tell me if its possible to communicate between a service and a form application. For example, retrieve information from the service, like current activity or progress of its operations. In particular, I would like to to monitor more than just whether a service is running. In the system tray I would like to display whether the service is idle, or running a particular method. Is this possible? If so, should I be using...
3
1226
by: Przemo | last post by:
Hi, I have two applications. One is a WinForm (in future it will be a service) and gets some data from serial port and adds them into database. It can be named as a beck-end appliacation. The second one, fron-end application, is a WebForm user interface. I would like to inform the WinForm (or in future service) application from the WebApplication to make some processing, no matters how it will finish or what will happen - something like...
1
8200
by: Ollie Riches | last post by:
I am trying to use asynchronous logging using MSMQ and I have configured the properties as defined in the help (see below) I don't understand where the property 'MsmqPath' is in the app.config for MSMQDistrbutor.exe is it meant to be an aplication settings or an enterprise library setting in the app.config? I have tried creating an application setting value for it but it still fails to write to the logging destination? Also is this...
14
15877
by: Webbee | last post by:
I have a service built that is trying to read messages from a private que. When this tries to happen I get this error.... A workgroup installation computer does not support the operation From what I read I need to have my system setup on a domain, is this correct? For my dev work I'm not going to have that envirorment available and everything is tested on one laptop. Is there anything I can do? Thank you
7
2420
by: Ahmed Perlom | last post by:
Hi all, I am trying to start a windows application that has a GUI from a Windows service written in .NET 2.0. I have been searching on this for few days now with no avail. When using the System.Diagnostic.Process object to start the application (i.e Notepad), the new app runs and it is listed on the task manger list, but the GUI doesn't show up in the desktop of the current user. I am aware windows service (either LocalSystem,...
0
1348
by: Kevin A | last post by:
The problem is that the web application mysteriously shuts down (ending all sessions) due to a supposed 'configuration change'. By using ASP.Net Health Monitoring we can determine that the application occasionally raises a "Application is shutting down. Reason: Configuration changed." event during normal application usage. The only known way to duplicate this event is to manually save the web.config, which correctly triggers the event as...
5
4491
by: Benzi Eilon | last post by:
I have written a C# application which should run as a Windows Service. I must avoid having multiple instances of the application on one machine so I inserted the following code at the beginning of the Main() function: // if this is not the first instance of this application, exit // immediately. Allow only one instance in the system if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1)
1
2232
by: mikelujan | last post by:
Hi, Our application starts an external application using System.Diagnostics.Process class and the Start() method, as per code snippet below. This application run as a Windows service, and must start several instances of the same application, like multiple Windows Calculators for instance. We are experiencing difficulties starting applications after a certain number have been started. We changed our app to work as a Console...
0
9673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10452
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10169
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5569
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.