Export (0) Print
Expand All

ServiceHostFactory Constructor

Initializes a new instance of the ServiceHostFactory class.

Namespace:  System.ServiceModel.Activation
Assembly:  System.ServiceModel.Activation (in System.ServiceModel.Activation.dll)

public ServiceHostFactory()

This examples show how to use the ServiceHostFactory:

	<ServiceContract> _
	Public Interface IHelloContract
		<OperationContract> _
		Function Hello(ByVal message As String) As String 
	End Interface 

	Public Class HelloService
		Implements IHelloService
		<OperationBehavior(Impersonation := ImpersonationOption.Required)> _
		Public Function Hello(ByVal message As String) As String Implements IHelloService.Hello
			Return "hello" 
		End Function 
	End Class 

	Public Class DerivedHost
		Inherits ServiceHost

		Public Sub New(ByVal t As Type, ParamArray ByVal baseAddresses() As Uri)
			MyBase.New(t, baseAddresses)
		End Sub 

		Protected Overrides Sub OnOpening()
			' add code here  
		End Sub 

		Shared Sub Main()
			Dim factory As New ServiceHostFactory()
		End Sub
	public interface IHelloContract
				string Hello(string message);

	public class HelloService : IHelloService
		[OperationBehavior(Impersonation = ImpersonationOption.Required)]
		public string Hello(string message)
			return "hello";
	public class DerivedHost : ServiceHost 

		public DerivedHost( Type t, params Uri[] baseAddresses ) : 
						base( t, baseAddresses ) {} 

		protected override void OnOpening() 
			// add code here 

		static void Main()
			ServiceHostFactory factory = new ServiceHostFactory();
		static void Main()
			ServiceHostFactory factory = new ServiceHostFactory();

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 3.5 SP1
© 2015 Microsoft