Investigating .NET Reflection API I understood that it is possible to change private fields/properties values using reflection and security is controlled by reflection permissions in that case. My question is how to control whether code can have an access to private fields or not? From MSDN:
To allow code to invoke any nonpublic member: Your code must be granted ReflectionPermission with the ReflectionPermissionFlag.MemberAccess flag.
How can I make my class private fields to be non-visible to code that uses reflection? What are the best practices on doing that?