如何:创建客户端激活的类型的实例
此代码示例显示如何创建客户端激活的类型的实例,它假设已注册 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 的命名空间的引用。