Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

What is the purpose of WCF Service Library? I understand if you build an IIS hosted service you create a web project, if self-hosted - create an .exe.

What is a real life scenario to use WCF as DLL?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
349 views
Welcome To Ask or Share your Answers For Others

1 Answer

While it's true that creating a WCF service as a class library gives you more flexibility, that flexibility comes at a cost, and it's a mistake to assume that the more flexible solution is always the preferred solution, or that the less flexible solution is childish or only suitable for "simple instructional purposes".

The vast majority of WCF services are hosted as web services and will never be deployed any other way.

Here are three advantages of using a WCF service application as opposed to a WCF class library:

  1. If you create your web service as a class library the configuration files will be app.config files rather than web.config files. App.config files don't natively support multiple configuration files and config transforms the way web.config files do. If you want config transforms on your app.config files you have to use a third party solution such as Slow Cheetah.

  2. When it's time to publish your site, if you use a WCF service application you can take full advantage of Web Deploy (http://www.iis.net/downloads/microsoft/web-deploy) which is a powerful and flexible way to publish your solution to IIS.

  3. If you decide to automate your build and deploy for continuous integration with TFS there will come a time when you'll want to automate the publishing of your service. If you use a WCF service you can configure TFS to run Web Deploy, which will merge your web.config files according to the target build configuration, perform incremental publish, enable publishing without administrator rights on the server and other benefits. If you use a WCF class library then you will have to write a custom workflow solution to merge the app.config files, use xCopy for deployment, and generally have a tougher time automating the deployment.

In summary the more flexible solution, as is often the case, comes at the cost of losing specific tool support. If, like most WCF service solutions, your application will always be hosted in IIS, you might consider taking advantage of this support by using a WCF service application as opposed to a WCF class library.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...