如何建立用戶端啟動型別的執行個體
這個程式碼範例顯示如何建立用戶端啟動型別的執行個體,假設已將 TcpChannel 註冊為接聽連接埠 8080。
範例
Dim Object() = {New UrlAttribute("tcp://computername:8080/RemoteObjectApplicationName ")}
' Note that the second parameter (Nothing) specifies that no arguments
' are being passed.
Dim MyRemoteClass As RemoteObjectClass = _
CType( _
Activator.CreateInstance(GetType(RemoteObjectClass), Nothing, url), _
RemoteObjectClass)
object[] url = {new UrlAttribute("tcp://computername:8080/RemoteObjectApplicationName")};
// Note that the second parameter (null) specifies that no arguments
// are being passed.
RemoteObjectClass MyRemoteClass = (RemoteObjectClass)Activator.CreateInstance(
typeof(RemoteObjectClass),
null,
url
);
編譯程式碼
這個範例需要:
- System 和 System.Runtime.Remoting.Activation 命名空間的參考,以及實作 RemoteObjectClass 的命名空間。