.NET で文字列を Type オブジェクトに変換する最良の方法は何ですか?
考慮すべき問題:
- 型が別のアセンブリにある可能性があります。
- 型のアセンブリがまだ読み込まれていない可能性があります。
これは私の試みですが、2番目の問題には対処していません
Public Function FindType(ByVal name As String) As Type
Dim base As Type
base = Reflection.Assembly.GetEntryAssembly.GetType(name, False, True)
If base IsNot Nothing Then Return base
base = Reflection.Assembly.GetExecutingAssembly.GetType(name, False, True)
If base IsNot Nothing Then Return base
For Each assembly As Reflection.Assembly In _
AppDomain.CurrentDomain.GetAssemblies
base = assembly.GetType(name, False, True)
If base IsNot Nothing Then Return base
Next
Return Nothing
End Function