I am trying to get the value of local path by doing the following:
Dim bar As WebProxy = WebProxy.GetDefaultProxy
Dim scriptEngine = bar.GetType().GetProperty("ScriptEngine", Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Instance)
Dim acs As PropertyInfo = scriptEngine.PropertyType().GetProperty("AutomaticConfigurationScript", Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Instance)
Dim localPath As PropertyInfo = acs.PropertyType().GetProperty("LocalPath", Reflection.BindingFlags.Public Or Reflection.BindingFlags.Instance)
Dim value As String = localPath.GetValue(acs, Nothing).ToString
I am pretty sure that the problem here is that I am passing a PropertyInfo object into localPath.GetValue, not the actual object itself. The only problem is that i can not cast the result of
Dim acs As PropertyInfo = scriptEngine.PropertyType().GetProperty("AutomaticConfigurationScript", Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Instance)
into a System.Uri AutomaticConfigurationScript and pass that in, therefore I get an error "Object does not match target type".
Any ideas?
P.S I realise this is not a c# question, but not wanting to limit the possible answers I have tagged it as such as it is a .Net question and If i receive an answer in C# i can translate.