I remember reading briefly that you can add assembly attributes so that you can only allow specific assemblies to call into an assembly. But I can’t remember where I saw that or how to do it – can someone point me in the right direction?
Just to be clear, this question is asking:
- I have assembly A and assembly B.
- Assembly B needs to access some member(s) within assembly A.
- Both assemblies will be sent to others in the form of a software product.
- I only want assembly B to be able to see the members in assembly A.
- Anyone who needs to use something in assembly A will have to do so via assembly B. Assembly A’s members are all hidden/internal so 3rd parties can not see them.
You can use the InternalsVisibleTo Attribute to allow assemblies referencing your assembly to see classes and members marked as
internal. I believe there is no way to prevent an assembly to reference your assembly and access allpublicclasses and members.Note: using reflection, any assembly can access any class or member, regardless of whether that is
publicorinternal(orprivate), provided the application is running with Full Trust (which is usually the case).