Public Sub New(ByVal oldC As Control)
Dim FQTN As String = oldC.GetType.FullName
Dim t As Type = Type.GetType(FQTN)
Dim newC As Object = Activator.CreateInstance(t)
End Sub
FQTN
返回正确的类型名称,但t
Nothing
。例如,FQTN = System.Windows.Forms.Panel
.
摆脱FQTN
.
这适用于您正在寻找的面板示例
Public Sub New(ByVal oldC As Control)
Dim t As Type = oldC.GetType()
Dim newC As Object = Activator.CreateInstance(t)
End Sub
此外,这是 Type.GetType("namespace.a.b.ClassName") 返回 null 的副本