Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reflection restrictions in Silverlight

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?

like image 874
Andir Avatar asked Feb 17 '10 19:02

Andir


1 Answers

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.

like image 170
Gabe Avatar answered Sep 20 '22 12:09

Gabe