我在尝试通过反射实例化WebProxy实例时遇到了这种奇怪的现象:
Dim proxyType As Type = GetType(System.Net.WebProxy)
MsgBox(proxyType.FullName)
Dim reflProxyType As Type = Type.GetType(proxyType.FullName)
MsgBox(reflProxyType.FullName) ' Here, reflProxyType is null => NullReferenceException
将第一行更改为其他系统命名空间(即System.Text.StringBuilder或System.String)可以正常工作。
Dim systemType As Type = GetType(System.Text.StringBuilder)
MsgBox(systemType.FullName)
Dim reflSystemType As Type = Type.GetType(systemType.FullName)
MsgBox(reflSystemType.FullName) ' Here, everything works fine
这种行为有什么理由吗?我错过了什么吗? MS是否对System.dll设置了一些限制?