将ObjectHandle转换为UserControl
本文关键字:UserControl 转换 ObjectHandle | 更新日期: 2023-09-27 18:17:06
如何强制转换Remoting。对象句柄到UserControl类型?
我想动态实例化UserControl:
UserControl myUserControl = (UserControl)Activator.CreateInstance(Assembly.GetExecutingAssembly().FullName, "Client.IndexView");
错误: 不能强制转换'System.Runtime.Remoting '类型的表达式。objecthhandle ' to 'UserControl'
如果您使用Unwrap
方法:
var instance = Activator.CreateInstance(Assembly.GetExecutingAssembly().FullName, "Client.IndexView");
UserControl myUserControl = (UserControl)instance.Unwrap();