我將我的程序連接到某些外部代碼。我設置它,以便外部代碼可以實例對象,我遇到了問題。我創建了這個功能在這裏:返回與名稱關聯的對象
Public Function InstanceOf(ByVal typename As String) As Object
Dim theType As Type = Type.GetType(typename)
If theType IsNot Nothing Then
Return Activator.CreateInstance(theType)
End If
Return Nothing
End Function
我試圖創建一個System.Diagnostics.Process
對象。不過,儘管如此,它總是返回Nothing
而不是對象。有人知道我在做什麼錯嗎?
我在VB.net這樣使所有的.NET迴應被接受:)
如何確定一切的完全限定名? (即你是怎麼想出這個名字的?) – FreeSnow 2012-02-03 01:31:17
如果你可以訪問這個類型,那麼'typeof(Process).AssemblyQualifiedName'就會返回它。 – svick 2012-02-03 01:48:02