I want to get access to the m_Info field of Uri class to change some fields inside. but uriInfo.GetValue(uri) returns null.
var uri = new Uri("https://stackoverflow.com/questions/12993962/set-value-of-private-field"); var uriInfo = typeof(Uri).GetField("m_Info", BindingFlags.NonPublic | BindingFlags.Instance); var infoField = uriInfo.GetValue(uri); the code works fine for my test class with the same structure as Uri but it fails for the System.Uri class. Any ideas?
m_Info? it is not required to share an implementation with the .NET Framework implementation. And on a protected environment such as android: it is not required to let you have access to the insides at all. What is it that returnsnull? is it theGetField? or theGetValue?