Internal access modifier visibility error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I've tried to limit access to some properties of externally exposed objects by applying the internal modifier, since the properties are to be modified from elsewhere in there declaring assembly.
However, its the properties seems to be accessable thorugh reflection, by way of GetProperty and SetValue.
I think this must surely be a bug. If not, the internal modifier is useless.

Does anyone know a way to get around this or know if it has been accepted as a bug by Microsoft ?

Regards

Per Millard
 
=?Utf-8?B?UGVyIE1pbGxhcmQ=?= said:
I've tried to limit access to some properties of externally exposed
objects by applying the internal modifier, since the properties are
to be modified from elsewhere in there declaring assembly.
However, its the properties seems to be accessable thorugh reflection,
by way of GetProperty and SetValue.
I think this must surely be a bug. If not, the internal modifier is
useless.

Does anyone know a way to get around this or know if it has been
accepted as a bug by Microsoft ?

It's not a bug - it just depends on how trusted your code is. If you're
running your code will full trust, you can do that. If you're not, you
can't.

That doesn't just go for internal - it's the same for private as well.

Even if there were no way of policing this, it would still be useful as
a way of telling developers what they should and shouldn't be accessing
in order to use a class properly. Fortunately, however, you can change
your security policy for various different configurations.

For instance, put your code on a network share and try executing it,
and you may well get an exception.
 
Back
Top