K
Karch
I am writing a WCF Service using MSMQ hosted in a Windows Service on Windows
XP. All the required components are installed (.NET3, MSMQ, etc).
For some reason my service tries to start and then stops right away. I have
looked at everything and can't see anything wrong - in fact, I started this
a few weeks ago and I swear it was running at one point.
I have included the app.config and service code below - any idea why my
service will not stay running? Thanks!
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<!-- use appSetting to configure MSMQ queue name -->
<add key="queueTarget" value=".\private$\NodeManagerXact" />
</appSettings>
<system.serviceModel>
<services>
<service name="Node.Manager.MessagingService"
behaviorConfiguration="MessagingServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/Node.Manager/service"/>
</baseAddresses>
</host>
<!-- Define NetMsmqEndpoint -->
<endpoint address="net.msmq://localhost/private/NodeManagerXact"
binding="netMsmqBinding"
contract="Node.Manager.IMessenger" />
<endpoint address=""
binding="wsHttpBinding"
contract="Node.Manager.IMessenger" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<!--For debugging purposes set the includeExceptionDetailInFaults attribute
to true-->
<behaviors>
<serviceBehaviors>
<behavior name="MessagingServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
[RunInstaller(true)]
public class NodeManagerInstaller : Installer
{
private ServiceProcessInstaller process;
private ServiceInstaller service;
public NodeManagerInstaller()
{
process = new ServiceProcessInstaller();
process.Account = ServiceAccount.LocalSystem;
service = new ServiceInstaller();
service.ServiceName = "NodeManagerService";
Installers.Add(process);
Installers.Add(service);
}
}
public partial class NodeManagerService : ServiceBase
{
public ServiceHost serviceHost = null;
public static void Main()
{
// Get MSMQ queue name from appsettings in configuration.
string queueName = ConfigurationManager.AppSettings["queueTarget"];
// Create the transacted MSMQ queue if necessary.
if (!MessageQueue.Exists(queueName))
MessageQueue.Create(queueName, true);
ServiceBase.Run(new NodeManagerService());
}
public NodeManagerService()
{
InitializeComponent();
ServiceName = "NodeManagerService";
}
protected override void OnStart(string[] args)
{
if (serviceHost != null)
{
serviceHost.Close();
}
serviceHost = new ServiceHost(typeof(MessagingService));
serviceHost.Open();
}
protected override void OnStop()
{
if (serviceHost != null)
{
serviceHost.Close();
serviceHost = null;
}
}
}
XP. All the required components are installed (.NET3, MSMQ, etc).
For some reason my service tries to start and then stops right away. I have
looked at everything and can't see anything wrong - in fact, I started this
a few weeks ago and I swear it was running at one point.
I have included the app.config and service code below - any idea why my
service will not stay running? Thanks!
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<!-- use appSetting to configure MSMQ queue name -->
<add key="queueTarget" value=".\private$\NodeManagerXact" />
</appSettings>
<system.serviceModel>
<services>
<service name="Node.Manager.MessagingService"
behaviorConfiguration="MessagingServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/Node.Manager/service"/>
</baseAddresses>
</host>
<!-- Define NetMsmqEndpoint -->
<endpoint address="net.msmq://localhost/private/NodeManagerXact"
binding="netMsmqBinding"
contract="Node.Manager.IMessenger" />
<endpoint address=""
binding="wsHttpBinding"
contract="Node.Manager.IMessenger" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<!--For debugging purposes set the includeExceptionDetailInFaults attribute
to true-->
<behaviors>
<serviceBehaviors>
<behavior name="MessagingServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
[RunInstaller(true)]
public class NodeManagerInstaller : Installer
{
private ServiceProcessInstaller process;
private ServiceInstaller service;
public NodeManagerInstaller()
{
process = new ServiceProcessInstaller();
process.Account = ServiceAccount.LocalSystem;
service = new ServiceInstaller();
service.ServiceName = "NodeManagerService";
Installers.Add(process);
Installers.Add(service);
}
}
public partial class NodeManagerService : ServiceBase
{
public ServiceHost serviceHost = null;
public static void Main()
{
// Get MSMQ queue name from appsettings in configuration.
string queueName = ConfigurationManager.AppSettings["queueTarget"];
// Create the transacted MSMQ queue if necessary.
if (!MessageQueue.Exists(queueName))
MessageQueue.Create(queueName, true);
ServiceBase.Run(new NodeManagerService());
}
public NodeManagerService()
{
InitializeComponent();
ServiceName = "NodeManagerService";
}
protected override void OnStart(string[] args)
{
if (serviceHost != null)
{
serviceHost.Close();
}
serviceHost = new ServiceHost(typeof(MessagingService));
serviceHost.Open();
}
protected override void OnStop()
{
if (serviceHost != null)
{
serviceHost.Close();
serviceHost = null;
}
}
}