Tag: reflectionpermission

读取用户会话时出现NULL引用exception(reflection)

我已经使用引用阅读所有用户会话实现了用于读取活动会话的代码,并获取了ASP.NET中所有活动会话的列表 。 Private List getOnlineUsers() { List activeSessions = new List(); object obj = typeof(HttpRuntime).GetProperty(“CacheInternal”, BindingFlags.NonPublic | BindingFlags.Static).GetValue(null, null); object[] obj2 = (object[])obj.GetType().GetField(“_caches”, BindingFlags.NonPublic | BindingFlags.Instance).GetValue(obj); for (int i = 0; i < obj2.Length; i++) { Hashtable c2 = (Hashtable)obj2[i].GetType().GetField("_entries", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(obj2[i]); foreach (DictionaryEntry entry in c2) { object o1 = entry.Value.GetType().GetProperty("Value", BindingFlags.NonPublic | […]