WCF Host/Windows Service
Old forum URL: forums.lhotka.net/forums/t/5206.aspx
whelzer posted on Thursday, August 07, 2008
I'm trying to set my app up to to use WCF Data portal and an very near getting it working but one area is killing me....
Using VS 2005, VB, CSLA 3.04 all on a local domain
For my WCF host I've created a Win Forms app and have the following on a button:
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
_host = New ServiceHost(GetType(Csla.Server.Hosts.WcfPortal), New Uri("net.tcp://localhost:8008"))
_host.Open()
btnStart.Enabled = False
btnStop.Enabled = True
End Sub
Where _host is of type ServiceHost.
This works ok - my client is running fine, so I'm assuming that my app.configs' are all ok aswell.
When I click Stop, client gives back "correct" exception.
Rather than have WCF host in a Windows App I'd like to have it as a Windows Service.
I've no issues with creating a WS, I'm just not sure how to hook up my WCF service into one.
Any ideas much appreciated.
Thanks
RockfordLhotka replied on Friday, August 08, 2008
You should start by reading up (on MSDN or elsewhere) on how to build a Windows Service. It isn't terribly hard, thanks to base classes already existing in .NET.
When the service is started, a method executes (you override it if I remember right). In that method, you are supposed to start doing your work on a background thread.
Of course WCF listens on a background thread automatically - so this is trivial. Just put your two lines of code into that start method and you are done. (well...you also need code in the stop method to close down the listener)
jeffq replied on Wednesday, July 29, 2009
Would you mind sharing a copy of your app.config for this incredibly simple app?Copyright (c) Marimer LLC