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" ?>
<configuratio n>
<appSettings>
<!-- use appSetting to configure MSMQ queue name -->
<add key="queueTarge t" value=".\privat e$\NodeManagerX act" />
</appSettings>
<system.service Model>
<services>
<service name="Node.Mana ger.MessagingSe rvice"
behaviorConfigu ration="Messagi ngServiceBehavi or">
<host>
<baseAddresse s>
<add baseAddress="ht tp://localhost:8000/Node.Manager/service"/>
</baseAddresses>
</host>
<!-- Define NetMsmqEndpoint -->
<endpoint address="net.ms mq://localhost/private/NodeManagerXact "
binding="netMsm qBinding"
contract="Node. Manager.IMessen ger" />
<endpoint address=""
binding="wsHttp Binding"
contract="Node. Manager.IMessen ger" />
<endpoint address="mex"
binding="mexHtt pBinding"
contract="IMeta dataExchange" />
</service>
</services>
<!--For debugging purposes set the includeExceptio nDetailInFaults attribute
to true-->
<behaviors>
<serviceBehavio rs>
<behavior name="Messaging ServiceBehavior ">
<serviceMetadat a httpGetEnabled= "True"/>
<serviceDebug includeExceptio nDetailInFaults ="False" />
</behavior>
</serviceBehavior s>
</behaviors>
</system.serviceM odel>
</configuration>
[RunInstaller(tr ue)]
public class NodeManagerInst aller : Installer
{
private ServiceProcessI nstaller process;
private ServiceInstalle r service;
public NodeManagerInst aller()
{
process = new ServiceProcessI nstaller();
process.Account = ServiceAccount. LocalSystem;
service = new ServiceInstalle r();
service.Service Name = "NodeManagerSer vice";
Installers.Add( process);
Installers.Add( service);
}
}
public partial class NodeManagerServ ice : ServiceBase
{
public ServiceHost serviceHost = null;
public static void Main()
{
// Get MSMQ queue name from appsettings in configuration.
string queueName = ConfigurationMa nager.AppSettin gs["queueTarge t"];
// Create the transacted MSMQ queue if necessary.
if (!MessageQueue. Exists(queueNam e))
MessageQueue.Cr eate(queueName, true);
ServiceBase.Run (new NodeManagerServ ice());
}
public NodeManagerServ ice()
{
InitializeCompo nent();
ServiceName = "NodeManagerSer vice";
}
protected override void OnStart(string[] args)
{
if (serviceHost != null)
{
serviceHost.Clo se();
}
serviceHost = new ServiceHost(typ eof(MessagingSe rvice));
serviceHost.Ope n();
}
protected override void OnStop()
{
if (serviceHost != null)
{
serviceHost.Clo se();
serviceHost = null;
}
}
}