reflectionpermission

HttpRuntime CacheInternal NULL reference exception while reading user sessions (Reflection)

一世执手 提交于 2019-12-12 11:18:52
问题 After some updates on our windows servers(2008R2 ,2012) Asp.net application throwing error: var obj_1 = typeof(HttpRuntime).GetProperty("CacheInternal", BindingFlags.NonPublic | BindingFlags.Static); CacheInternal is coming null, dont know why ? following solution is not working :( Solution 回答1: I have find the solution. Now HTTPRuntime class doesnt have CacheInternal Property.So to achive the above task I have created a global list adding sessions in that list in Session_Start and removing

how to add Reflection Permission to IIS or to add it to web.config?

拜拜、爱过 提交于 2019-12-10 14:53:41
问题 I'm using FileHelpers for reading csv files, and all it was ok until I switched from VS dev server to IIS, I get a "PolicyException: Required permissions cannot be acquired" , I googled and found that I need to add Reflection Permission for this to work, anybody knows how ? 回答1: Your asp.net application is probably running in low-trust or medium trust. Reflection permission is in full trust. You can enable this specific Reflection Permission without going full trust by following this post by

NULL reference exception while reading user sessions (Reflection)

我的未来我决定 提交于 2019-12-07 06:16:55
问题 I have implemented the code for reading the active sessions using the reference Reading All Users Session and Get a list of all active sessions in ASP.NET. Private List<String> getOnlineUsers() { List<String> activeSessions = new List<String>(); 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)

NULL reference exception while reading user sessions (Reflection)

好久不见. 提交于 2019-12-05 09:17:23
I have implemented the code for reading the active sessions using the reference Reading All Users Session and Get a list of all active sessions in ASP.NET . Private List<String> getOnlineUsers() { List<String> activeSessions = new List<String>(); 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("