Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 954245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:11:00+00:00 2026-05-16T00:11:00+00:00

Does reflection break the idea of private methods? Because private methods can be accessed

  • 0

Does reflection break the idea of private methods? Because private methods can be accessed from outside of the class? (Maybe I don’t understand the meaning of reflection or miss something else, please tell me)
http://en.wikipedia.org/wiki/Reflection_%28computer_science%29

Edit:
If relection breaks the idea of private methods – do we use private methods only for program logic and not for program security?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T00:11:00+00:00Added an answer on May 16, 2026 at 12:11 am

    do we use private methods only for program logic and not for program security?

    It is not clear what you mean by "program security". Security cannot be discussed in a vacuum; what resources are you thinking of protecting against what threats?

    The CLR code access security system is intended to protect resources of user data from the threat of hostile partially trusted code running on the user’s machine.

    The relationship between reflection, access control and security in the CLR is therefore complicated. Briefly and not entirely accurately, the rules are these:

    • full trust means full trust. Fully trusted code can access every single bit of memory in the process. That includes private fields.

    • The ability to reflect on privates in partial trust is controlled by a permission; if it is not granted then partial trust code may not do reflection on privates.

    See Link for details.

    • The desktop CLR supports a mode called "restricted skip visibility" in which the rules for how reflection and the security system interact are slightly different. Basically,
      partially trusted code that has the right to use private reflection may access a private field via reflection if the partially trusted code is accessing a private field from a type that comes from an assembly with equal or less trust.

    See

    Link

    for details

    The executive summary is: you can lock partially trusted code down sufficiently that it is not able to use reflection to look at private stuff. You cannot lock down full trust code; that’s why it’s called "full trust". If you want to restrict it then don’t trust it.

    So: does making a field private protect it from the threat of low trust code attempting to read it, and thereby steal user’s data? Yes. Does it protect it from the threat of high trust code reading it? No. If the code is both trusted by the user and hostile to the user then the user has a big problem. They should not have trusted that code.

    Note that for example, making a field private does not protect a secret in your code from a user who has your code and is hostile to you. The security system protects good users from evil code. It doesn’t protect good code from evil users. If you want to make something private to keep it from a user then you are on a fool’s errand. If you want to make it private to keep a secret from evil hackers who have lured the user into running hostile low-trust code then that is a good technique.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

System.Reflection does not (AFAIK) support reflecting on global methods in an assembly. At the
Does C# offer a way to create Enum type from scratch using reflection? Suppose,
Does anyone have any references for building a full Object/Class reflection system in C++
As explained in this thread Find a private field with Reflection? reflection can be
Does creating an object using reflection rather than calling the class constructor result in
Does anyone knows how can I invoke method dynamically without reflection? I`ll try to
After Getting a System.Reflection.PropertInfo array for a class- Does anyone know how or if
Does system.Reflection work when I use release folder ?
I am interested to know the technical reasons: why does reflection not perform well
Does it needs reflection?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.