How to determine if a class / method is available using reflection?

I use dynamic assembly to create derived classes at runtime. How can I say, using reflection, is it possible to use / call the base class and individual methods in the base class from a derived class in a dynamic assembly?

+4
source share
1 answer

MethodInfo and Type objects have a number of properties that can be used to request visibility.

For example, for a type, you can check IsPublic , IsPrivate , IsNotPublic , IsNested , IsNestedFamOrAssembly and much more.

For the method ( MethodInfo object) you have a similar set: IsPublic , IsPrivate , IsFamilyOrAssembly , etc.

So, combine this with information similar to the Assembly property for the type (so that you can determine if types 1 and 2 are in the same assembly) and you can get all the necessary information.

+3
source

Source: https://habr.com/ru/post/1313004/


All Articles