473,320 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

WCF hosted in Windows Service

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;

}

}

}
Mar 9 '07 #1
1 6403
Nevermind - I found the problem. I was specifying MSMQ binding which doesn't
support the two-way communication specified in my contract. Thanks anyway -
hopefully this helps someone else. :-)

"Karch" <no****@absotutely.comwrote in message
news:e$*************@TK2MSFTNGP04.phx.gbl...
>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;

}

}

}


Mar 9 '07 #2

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

Similar topics

8
by: Julia | last post by:
Hi, My client uses a remote object when I host the remote object inside a windows application all seem to work fine but when I host the same object inside a windows service I get the following...
5
by: Nate | last post by:
We are attempting to make a request to a web service (we will refer to it as XXXServices) hosted on a Web Logic server from a C# SOAP client. The server responds with a 401 Unauthorized error...
5
by: Segfahlt | last post by:
I need a little help here please. I have 2 win forms user controls in 2 different projects that I'm hosting in 2 different virtual directories. The controls have been test and operate okay in...
0
by: vasu devan | last post by:
Dear Gurus, My ASP.NET website is running on .NET 1.1. hosted in windows server 2003 enterprise edition. We are having two sites. They are 1. One internet site 2. One intranet site. Both...
0
by: Vasu | last post by:
Hi All, My ASP.NET website is running on .NET 1.1. hosted in windows server 2003 enterprise edition. We are having two sites. They are 1. One internet site 2. One intranet site. Both...
0
by: kCura | last post by:
I've got an web application that's using a hosted form in IE. The server that is hosting it is running Windows Server 2003 with SP1 and the .NET 1.1 framework. It has all of the latest and greatest...
0
by: =?Utf-8?B?QWRyaWFuIENvbGU=?= | last post by:
I have written a simple WCF service hosted in a Windows console application and a simple WCF client console application that connects successfully to that service and retrieves data. I then ported...
5
by: paul korosi | last post by:
Hi, I've got a wcf service that is hosted on my local machine. I need to determine the hosted url of the service from within the service but cannot work out how to do it. HttpContext.Current...
0
by: khurramlone | last post by:
I am trying to generate a client proxy from a WCF service library. I am using VS2005, .NET 3.0 on a Windows XP Pro workstation. The WCF service is hosted in a windows service. When I run the windows...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.