views:

345

answers:

1

Where described well-known reflection restrictions for Silverlight types?

For example: if I try to set protected or private property value with PropertyInfo.SetValue method I get an exception MethodAccessException.

Why did these restrictions?

+3  A: 

For security purposes, reflection in Silverlight is limited to what is available at compile time. Mostly this means you can only access public members.

Here's what MS says about it: http://msdn.microsoft.com/en-us/library/stfy7tfc(VS.95).aspx

The reason for this is that the Silverlight internals are mostly private or internal to the main Silverlight assembly. If I could call those private functions without any parameter checking, I might be able to write a Silverlight app that reads your private files or something like that.

Gabe
Well, but where described that behavior?Which "security purposes" you know?
Andir