What is the correct way to create a WCF service in separate assembly but then expose its endpoint through a Web Project in the same solution?
I've done it this way:
MyServiceLib
Add to your web project a file like MyService.svc
with only one statement, the ServiceHost directive:
<%@ ServiceHost Service="MyServiceLib.MyService" %>
where MyServiceLib
is the name of the namespace of your WCF service and MyService
the name of your service implementation class. (This simple setup is for the case when you deploy your service as a compliled assembly (in the Bin
directory for instance). If you want to deploy with source and let complile on first request you need to put some more attributes to the service host directive (Programming language, Source file, etc.)
web.config
in the <system.serviceModel>
section.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With