如何将Remoting.ObjectHandle转换为UserControl类型?
我想动态实现UserControl:
UserControl myUserControl = (UserControl)Activator.CreateInstance(Assembly.GetExecutingAssembly().FullName, "Client.IndexView");
错误:无法将“System.Runtime.Remoting.ObjectHandle”类型的表达式转换为“UserControl”
答案 0 :(得分:6)
如果您使用Unwrap
方法怎么办:
var instance = Activator.CreateInstance(Assembly.GetExecutingAssembly().FullName, "Client.IndexView");
UserControl myUserControl = (UserControl)instance.Unwrap();