What is the difference between a WCF Service Application and a WCF Service Library?

谁说我不能喝 提交于 2019-11-26 07:57:59

问题


I am developing a WCF web service and I used the WCF Service Application template to do that.

Does creating a \"WCF Service Application\" fulfill this requirement? What are the advantage of creating a WCF Service Library over a WCF Service Application?


回答1:


A service application includes a website host already setup for you. A service library is a library of services that a host can reference and startup.

If you start with a service library (recommended) you can then choose any host you wish (a windows service, IIS/ASP.NET, or even a console application) and you'd just reference your library from your new host. Choosing a Service Application limits your host to just IIS/ASP.NET (though this might be ok for your purposes, but will limit the protocols you can use).

Edit: Changes in IIS since I wrote this allow for a wider variety of protocols on ASP.NET activated services, so choosing a service application is much less limiting than before.




回答2:


If all you have is the one project I see only added complexity if you separate for the heck of it. I used a library when I had some particular use cases where I had to host in both a windows service and in IIS.

For IIS you you can move the classes and interfaces to a library but keep your .SVC files in the web project. You must edit the .SVC files to point to the properly qualified classes.



来源:https://stackoverflow.com/questions/1204365/what-is-the-difference-between-a-wcf-service-application-and-a-wcf-service-libra

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!