2011-12-08 69 views
3

如何將Remoting.ObjectHandle投射到UserControl類型?將ObjectHandle投射到UserControl

我想動態實例化一個用戶控件:

UserControl myUserControl = (UserControl)Activator.CreateInstance(Assembly.GetExecutingAssembly().FullName, "Client.IndexView"); 

錯誤無法施展'System.Runtime.Remoting.ObjectHandle類型的表達式爲 '用戶控件'

回答

5

如果什麼您使用Unwrap方法:

UserControl myUserControl = (UserControl)Activator.CreateInstance(Assembly.GetExecutingAssembly().FullName, "Client.IndexView").Unwrap();