/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
samples/snippets/visualbasic/VS_Snippets_CFX/faultcontractattribute/vb/hostapplication.vb
40 строк
2 KB
Next Turn
Format codes based on .editorconfig, Part 4 (#18853)
08 июн 2020, 22:49
Не верифицирован
08 июн 2020, 22:49
7e34efc
Код
Авторство
О чём код?
Imports System.Configuration Imports System.Collections.Generic Imports System.ServiceModel Imports System.Text Namespace Microsoft.WCF.Documentation Friend Class HostApplication Shared Sub Main() Dim app As New HostApplication() app.Run() End Sub Private Sub Run() ' Create a ServiceHost for the service type and use the base address from configuration. Using serviceHost As New ServiceHost(GetType(SampleService)) Try ' Open the ServiceHostBase to create listeners and start listening for messages. serviceHost.Open() ' The service can now be accessed. Console.WriteLine("The service is ready.") Console.WriteLine("Press <ENTER> to terminate service.") Console.ReadLine() ' Close the ServiceHostBase to shutdown the service. serviceHost.Close() Catch timeProblem As TimeoutException Console.WriteLine("The service operation timed out. " & timeProblem.Message) Console.ReadLine() serviceHost.Abort() Catch commProblem As CommunicationException Console.WriteLine("There was a communication problem. " & commProblem.Message) Console.ReadLine() serviceHost.Abort() End Try End Using End Sub End Class End Namespace