简体   繁体   中英

WCF with Windows service hosting for Host and Client

I have a WCF with Windows service hosting for a background DB operation. I have included the client part also in the same windows service with a timer instead of creating a seperate windows service for the client part. I would like to know is there any drawback with this approach.

必须与@Kek达成共识,如果没有外部调用者,为什么要完全使用WCF服务:)除了与使用2个Windows服务相比没有真正的缺点之外,您的方法使用的内存更少,并且只有一个服务可以管理(启动,停止等)。

I agree with @Tommy Grovnes in most cases: no drawback if things are done correctly. I'd like to point out something though:

If service and client are in the same process, certainly the later depends on the former... and you may be tempted to call service methods directly (without using WCF actually)... Try not to do that.

If you do, your data is not serialized : so it is faster, but it may not behave the exact same way compared to a client in another process.

This is particulary true if you use mechanisms such as EF Self tracking entities. These entities change their state when they are deserialized. Avoiding the serialization may lead to unexpected errors when you actually call your service from another process.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM