Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the WCF self-hosting host?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what is the WCF self-hosting host". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the WCF self-hosting host".

Using the Open () and Close () methods provided by ServiceHost provided by WCF, it is convenient for developers to host services in console applications, Windows applications, and even ASP.NET applications. The way services are hosted is essentially the same regardless of the application in the home-hosting environment. For example, in a console application:

Using (ServiceHost host = new ServiceHost (typeof (DocumentsExplorerService) {host.Open (); Console.WriteLine ("The Service had been launched."); Console.Read ();}

The ServiceHost instance is created in the application domain, so we must ensure that the host process is not shut down during service invocation, so we use Console.Read () to block the process so that the console application can keep running until the application is presumably closed. If it is a Windows application, you can place the code that creates the ServiceHost instance in the relevant code of the main form to ensure that the service WCF self-managed host will not be closed. Accordingly, we need to configure the application's app.config configuration file:

Note that the service name in the configuration file must contain the service contract and the namespace of the service class. In addition, I added the base address to the service through the tag in the configuration file, so in endpoint, address is "".

Thank you for your reading. the above is the content of "what is a WCF self-hosting host". After the study of this article, I believe you have a deeper understanding of what the WCF self-hosting host is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report