Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relationship between SVC files and WCF projects?

Tags:

c#

iis

wcf

When creating a WCF project, the default member files are just ordinary csharp class files, rather than svc files. Are svc files required with a WCF project? When should they be used?

like image 384
Craig Schwarze Avatar asked Jan 21 '10 22:01

Craig Schwarze


People also ask

What is the use of SVC file in WCF?

svc file contains a WCF-specific processing directive (@ServiceHost) that allows the WCF hosting infrastructure to activate hosted services in response to incoming messages. The most common syntax for a . svc file is in the following statement. It consists of the @ServiceHost directive and a single attribute, Service .

What are SVC files used for?

Text file that contains information about a Windows Communication Foundation (WCF) service that can be run using Microsoft Internet Information Services (IIS); includes a WCF-specific processing directive that activates hosted services in response to incoming messages.

Where is .SVC file in WCF?

.svc file in WXF:- asmx file in web services. In other words, WCF services hosted in IIS are represented as special content files (. svc files) inside the IIS application. This model is similar to the way ASMX pages are represented inside of an IIS application as .

How do I create a .SVC file in WCF?

Using this directive is basically equivalent to creating a service host using the following code in your self hosting console program. new ServiceHost(typeof(MyNamespace. MyServiceImplementationTypeName )); And If your self hosted application are using WCF configuration like 'endpoint', 'binding',etc in the app.


2 Answers

.svc files are used when you host your WCF service in IIS.

See Microsoft's doc here and here.

There's a module within IIS that handles the .svc file. Actually, it is the ASPNET ISAPI Module, which hands off the request for the .svc file to one of the handler factory types that has been configured for ASPNET, in this case

System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089


If you are hosting your WCF service in something other than IIS, then you don't need the .svc file.

like image 82
Cheeso Avatar answered Sep 26 '22 01:09

Cheeso


If you are using .net 4.0 or later, you can now "simulate" the .svc via config with the following:

<system.serviceModel>    <!-- bindings, endpoints, behaviors -->    <serviceHostingEnvironment >       <serviceActivations>          <add relativeAddress="MyService.svc" service="MyAssembly.MyService"/>       </serviceActivations>    </serviceHostingEnvironment> </system.serviceModel> 

Then you don't need a physical .svc file nor a global.asax

like image 34
Sean B Avatar answered Sep 22 '22 01:09

Sean B