HttpListener HttpListener HttpListener Constructor

定義

初始化 HttpListener 類別的新執行個體。Initializes a new instance of the HttpListener class.

public:
 HttpListener();
public HttpListener ();
Public Sub New ()

例外狀況

這個類別不可用於目前作業系統。This class cannot be used on the current operating system. 需要 Windows Server 2003 或 Windows XP SP2,才能使用這個類別的執行個體。Windows Server 2003 or Windows XP SP2 is required to use instances of this class.

範例

下列程式碼範例將示範如何HttpListener使用此函式來HttpListener建立新的物件。The following code example demonstrates using the HttpListener constructor to create a new HttpListener object. 如需完整範例, 請參閱HttpListener類別主題。For the complete example, see the HttpListener class topic.

// Set up a listener.
HttpListener listener = new HttpListener();
foreach (string s in prefixes)
{
    listener.Prefixes.Add(s);
}
listener.Start();
For Each s As String In prefixes
    listener.Prefixes.Add(s)
Next

listener.Start()

備註

使用此函式所傳回的實例之前, 您必須先Start叫用其方法。Before using the instance returned by this constructor, you must invoke its Start method.

給呼叫者的注意事項

注意:在應用程式中啟用網路追蹤時,這個成員會輸出追蹤資訊。Note: This member outputs trace information when you enable network tracing in your application. 如需詳細資訊, 請參閱.NET Framework 中的網路追蹤For more information, see Network Tracing in the .NET Framework.

適用於