Deploying a WCF service both in IIS and as Windows service

Is it possible to have one WCF service project that can be deployed both as a Windows service and also as a web service hosted in IIS?  I would like to be able to do this without having to create two separate projects in Visual Studio, but I cannot figure out how to do it.

I have created a project of type "WCF Service Application" and I can get this working as a web service in IIS very easily.  Should I have used a different project type to be able to do the Windows service as well?
BRNIITAsked:
Who is Participating?
 
SriVaddadiConnect With a Mentor Commented:
Lets say you would go with hosting with managed windows service then your solution would have two projects.

1. WCF service itself
2. Windows service which would host your WCF service

WCF service would have two end points. One for http which is for hosting in IIS and another for hosting in windows service.
0
 
SriVaddadiCommented:
You could do it by creating two endpoints.

Also just in case you want to host in windows service then you would have to write the host also.

I am not sure of your scenario why you are preferring windows service. If it is just to support a protocol other than http then you could host it in WAS(Windows Process Activation Service) it supports HTTP,TCP, NAMED PIPES, MSMQ etc and provides all the features that IIS provides.

Note that WAS is available from Windows Vista and up and I guess Windows 2003 server and up
0
 
SriVaddadiCommented:
0
 
BRNIITAuthor Commented:
Thank you, SriVaddadi - that is a good suggestion.  I will look into that, but let's say I do want to use Windows services.  Isn't an .exe required, and therefore a console application project?  Would I have to copy code from one project to another, and maintain them both, or is there a way to do it with the same project and code?
0
 
BRNIITAuthor Commented:
Thank you for the information, SriVaddadi.  Very helpful.
0
All Courses

From novice to tech pro — start learning today.