Re[2]: доступ к private полям через FieldInfo
От: Аноним  
Дата: 07.12.04 16:00
Оценка:
Все-таки интересно было бы узнать, как в приведенном bobbisson коде можно из класса MyClass (сборки) запретить внешнему коду изменять private members. Может быть глубокоуважаемые зубры секьюрити расшифруют свои намеки, как именно приложить ReflectionPermission в данном контексте.

"One caveat with visibility is that even properly designed visibility of types in an application cannot protect against code that is granted the ReflectionPermission with the MemberAccess flag or the SecurityPermission with the SerializationFormatter flag. Any applications granted the ReflectionPermission with the MemberAccess flag can read and write to private fields, call private methods, and create instances of private classes. Applications that were granted the SecurityPermission with the SerializationFormatter permission can read or write private fields of classes if they can serialize them to a data blob, change that data blob, and deserialize it back to the class. These are considered powerful permissions, so they aren't granted to any Internet or intranet code by default." (с) .NET Framework Security by Brian A. LaMacchia, Sebastian Lange, Matthew Lyons, Rudi Martin, Kevin T. Price

Кроме как посредством not being granted ReflectionPermission у вызывающего кода (например, настройкой политики безопасности), как это сделать из вызываемого кода я не понимаю. Наверное туплю. Большая просьба намекнуть как это можно сделать.
Спасибо!
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.