我只是在尝试通过反射实例化 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 设置了一些限制?