tags:

views:

251

answers:

1

I need to add a .svc file to WCF Service Library I have added to a solution (This doesn't have the .svc file). If I specify this file through ad new item (eg test.svc), this is an installer file not the WCF file.

How can I add this file to my project?

Thanks

+1  A: 

You cannot add a .svc file to a WCF service library - you need to add the WCF service file to a ASP.NET web site or ASP.NET web application in your solution.

In a web application or web site, you can right click on the project, choose "Add New Item", and then pick "WCF Service" from the dialog. This will add the necessary .svc file to your web site or web app.

The svc file must to be in a web app/web site as a container - it cannot reside in a WCF service library.

Marc

marc_s
Thanks for that!
dotnetdev
I can't see why this is true. An .svc file is just a text file with the .svc extension. It never gets compiled, but is rather interpreted by IIS. You can put an .svc file together with a WCF binary and it will work if IIS is configured correctly. It doesn't matter what sort of Visual Studio project it is.
Mark Seemann
@Mark Seemann: as you say "it gets interpreted by IIS" - so you nee the IIS infrastructure for this to work - which is really only the case in web apps and web sites as VS.NET project types, no?
marc_s
Yes and no. I normally create a completely standard Windows Library (.dll) project and write my WCF services like that, then add the .svc file by hand if I need to host the service in IIS. The Visual Studio project type doesn't matter at run-time.
Mark Seemann
@Mark Seemann: sure - you can do it manually - no biggie. But since the svc file does require the IIS infrastructure, I guess it makes sense that it's available from the "Add New Item" context menu only in web site / web app projects
marc_s