访问级别修饰符与 C# 中的程序集加载

Access Level Modifiers versus Assembly Load in C#

默认情况下 类 在程序集中(在我的例子中是 DelegatesSampleApplication)是内部的。因此,除非将它们声明为该特定程序集的友元程序集,否则外部程序集不应该能够访问它们吗? 现在在另一个程序中,这对我来说绝对是一个不同的程序集(在我的例子中是 ReflectionSampleApplication),我试图通过反射 Assembly.LoadFrom 加载该程序集。我现在可以访问该程序集所谓的 "Internal" 类 中的类型对象。 这是预期的行为吗?我错过了什么吗?

And I am now able to access the type objects within the so called "Internal" classes of that assembly. Is that an expected behaviour ?

是的,这是预期的。

Am I missing something ?

访问修饰符用于控制 'normal' 编译代码中的访问。它们从来都不是要限制 Reflection。它们与任何方式的安全或保密无关,它们用于帮助组织您的代码。