Is it possible to get an abstract type from a given Assembly at runtime?
I am currently loading my assembly with:
Assembly assem = Assembly.LoadFrom("MyAssemblyName.dll");
But then I want to do this:
Type t = assem.GetType("Enterprise.Shared_Party_PersonType");
My class is defined as:
public abstract class Shared_Party_PersonType
But type t is returning null.
My final goal is to navigate an abstract class with reflection and get a list
of properties of that abstract class, similar to what they do here: access-to-properties-of-abstract-class-with-reflection
Any help will be very appreciated.
Solution: Turns out that I was loading the wrong version of the DLL, which didn’t contain the abstract type I was trying to load. However, now I know that you can navigate and manipulate abstract types with reflection as any other concrete type. Also I learned about Assembly.RefelectionOnlyLoadFrom method thanks to @Fuex to load an assembly in reflection-only context
Maybe your class is defined inside some other class. In that case you must use a
+(plus) instead of a.(dot). Like this:where
Enterpriseis an “outer” class or struct thatShared_Party_PersonTypeis defined inside.Otherwise, can you access the source code of MyAssemblyName.dll? Then you might try to se what
string n = typeof(Shared_Party_PersonType).FullNamereturns in there, to check if the type name is really what you presume.