来自完全限定类型名称的 GetType 不起作用

GetType from fully qualified type name not working

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 返回正确的类型名称,但 tNothing。例如,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") returns null

的副本