문자열을 .NET의 Type 개체로 변환하는 가장 좋은 방법은 무엇입니까?.NET의 문자열에서 Type 개체를 가져 오는 가장 좋은 방법
문제는 고려해야 할
- 유형은 다른 어셈블리에있을 수 있습니다.
- 형식의 어셈블리가 아직로드되지 않았을 수 있습니다.
이 내 시도,하지만 당신은이 작업을 수행하기 위해 Type.GetType(string)를 사용할 수는 두 번째 문제를
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
두 번째 경우에 대한 설명은 어렵습니다. 언로드 된 어셈블리가 어디에 존재하는지 일반적으로 알 수있는 방법은 무엇입니까? 그렇지 않으면 [이 답변] (http://stackoverflow.com/a/7286354/661933)을 참조하십시오. – nawfal