[英]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
is returning the correct Type name, but t
is Nothing
. FQTN
返回正确的Type名称,但t
为Nothing
。 For instance, FQTN = System.Windows.Forms.Panel
. 例如, FQTN = System.Windows.Forms.Panel
。
Get rid of FQTN
. 摆脱FQTN
。
This works with the panel example you're looking for 这适用于您要查找的面板示例
Public Sub New(ByVal oldC As Control)
Dim t As Type = oldC.GetType()
Dim newC As Object = Activator.CreateInstance(t)
End Sub
Also, this is a duplicate of Type.GetType("namespace.abClassName") returns null 另外,这是Type.GetType(“ namespace.abClassName”)的重复, 返回null
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.