In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces you how to solve the problem of WCF self-hosting, the content is very detailed, interested friends can refer to, hope to be helpful to you.
After studying WCF for a long time, I also have a certain degree of understanding of WCF, so I will make my remarks here. WCF self-hosting is a technical term used when developers are responsible for providing and managing the life cycle of host processes. Since the host is applied in a process (or computer) boundary environment between the client and the service, and when using in-process services (that is, in the same process as the client).
The process you need to provide could be any Windows process, for example, a Windows forms application, a console application, or a Windows NT service. Note that the process must be run before the client invokes the service; typically, this means that you must start it in advance. This is not a problem for NT in-process services. Similar to IIS hosting, the WCF self-hosting application configuration file must list the types of services you want to host and expose them to the outside world. Also, the host process must explicitly register the service type at run time and open the host to facilitate client invocation. Typically, this is achieved using the helper class ServiceHost defined as follows in the Main () method:
Public interface ICommunicationObject: IDisposable {void Open (); void Close (); / / more members} public abstract class CommunicationObject: ICommunicationObject {...} public class ServiceHostBase: CommunicationObject,... {...} public class ServiceHost: ServiceHostBase,... {public ServiceHost (Type serviceType, params Uri [] baseAddresses); / / more members}
The information provided to the constructor of ServiceHost is the service type and (optional) default base address. The base address set can be an empty set (you can configure different base addresses later). Having a set of base addresses enables the service to accept calls on multiple addresses and protocols. Note that each ServiceHost instance is associated with a specific service type, and if the hosting process needs to host multiple types of services, you need some matching ServiceHost instances. By calling the ServiceHost.Open () method in the host, you allow call- in; and by calling the ServiceHost.Close () method, you can gracefully exit the host instance and finish sending data to the current client, while rejecting future client calls-even if the host process is still running. Typically, the shutdown occurs when the WCF shuts down from the host process. For example, to host this service in an Windows forms application:
[ServiceContract] interface IMyContract {...} class MyService: IMyContract {...} you can write: public static void Main () {Uri baseAddress = new Uri ("http://localhost:8000/"); ServiceHost serviceHost; serviceHost = new ServiceHost (typeof (MyService), baseAddress); serviceHost.Open (); / can intercept calls: Application.Run (new MyForm ()); serviceHost.Close () } on how to solve the WCF hosting problem has been shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.