WCFHost in Windows Service?

WCFHost in Windows Service?

Old forum URL: forums.lhotka.net/forums/t/7796.aspx


ludwigs3rd posted on Thursday, October 15, 2009

http://msdn.microsoft.com/en-us/library/cc949080.aspx#
So I'm following that guide to creating a Windows Service hosted WCF service but I'm unsure how to do this with the WCFHost example in the PTracker project. In the example you have to implement a service interface but that's a different type of WCF service from the WCFHost example in PTracker. Can someone offer some insight please?

Looking into the following how-to's also in case this is of interest to anyone:
http://msdn.microsoft.com/en-us/library/cc668805.aspx
http://www.codeproject.com/KB/dotnet/simplewindowsservice.aspx

sergeyb replied on Thursday, October 15, 2009

Here is an article that describes how to do it. Your host would be WcfPortal, so instead of
serviceHost = new ServiceHost(typeof(CalculatorService));
in the article you would have
serviceHost = new ServiceHost(typeof(WcfPortal));

You can copy all the settings from web.config sample into app.config of the windows service - they do not change.

Sergey Barskiy
Principal Consultant
office: 678.405.0687 | mobile: 404.388.1899

Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

-----Original Message-----
From: ludwigs3rd [mailto:cslanet@lhotka.net]
Sent: Thursday, October 15, 2009 12:41 PM
To: Sergey Barskiy
Subject: [CSLA .NET] WCFHost in Windows Service?

http://msdn.microsoft.com/en-us/library/cc949080.aspx#
So I'm following that guide to creating a Windows Service hosted WCF service but I'm unsure how to do this with the WCFHost example in the PTracker project. In the example you have to implement a service interface but that's a different type of WCF service from the WCFHost example in PTracker. Can someone offer some insight please?

sergeyb replied on Thursday, October 15, 2009

Missed the actual URL:
http://msdn.microsoft.com/en-us/library/ms733069.aspx


Sergey Barskiy
Principal Consultant
office: 678.405.0687 | mobile: 404.388.1899

Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation


-----Original Message-----
From: Sergey Barskiy [mailto:cslanet@lhotka.net]
Sent: Thursday, October 15, 2009 5:14 PM
To: Sergey Barskiy
Subject: RE: [CSLA .NET] WCFHost in Windows Service?

Here is an article that describes how to do it. Your host would be WcfPortal, so instead of
serviceHost = new ServiceHost(typeof(CalculatorService));
in the article you would have
serviceHost = new ServiceHost(typeof(WcfPortal));

You can copy all the settings from web.config sample into app.config of the windows service - they do not change.

Sergey Barskiy
Principal Consultant
office: 678.405.0687 | mobile: 404.388.1899

Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

-----Original Message-----
From: ludwigs3rd [mailto:cslanet@lhotka.net]
Sent: Thursday, October 15, 2009 12:41 PM
To: Sergey Barskiy
Subject: [CSLA .NET] WCFHost in Windows Service?

http://msdn.microsoft.com/en-us/library/cc949080.aspx#
So I'm following that guide to creating a Windows Service hosted WCF service but I'm unsure how to do this with the WCFHost example in the PTracker project. In the example you have to implement a service interface but that's a different type of WCF service from the WCFHost example in PTracker. Can someone offer some insight please?



ludwigs3rd replied on Thursday, October 15, 2009

Just got it working. This is what worked for me:

protected override void OnStart(string[] args)
{
if (myServiceHost != null)
{
myServiceHost.Close();
}
myServiceHost = new ServiceHost(typeof(Csla.Server.Hosts.WcfPortal), new Uri("http://192.168.1.137/MyService.svc"));
BasicHttpBinding binding = new BasicHttpBinding();
myServiceHost.AddServiceEndpoint("Csla.Server.Hosts.IWcfPortal", binding, "/", new Uri("http://192.168.1.137/MyService.svc"));
myServiceHost.Open();
}

Copyright (c) Marimer LLC