Ok I understood. For my purposes, which were just a simple type discovery for an assembly, but without instantiating, using Assembly.ReflectionOnlyLoad works if the assembly is 32-bit.
You load Assembly.ReflectionOnlyLoad and you are allowed to reflect types. You must also connect to AppDomain.CurrentDomain.ReflectionOnlyLoadResolve.
To get the attribute names, you need to use the CustomAttributeData.GetCustomAttributes attributes for the type, method or module.
static void Main(string[] args)
{
AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += new ResolveEventHandler(CurrentDomain_ReflectionOnlyAssemblyResolve);
Assembly assm = Assembly.ReflectionOnlyLoadFrom("TestProject1.dll");
Type t = assm.GetType("TestProject1.ProgramTest");
MethodInfo m = t.GetMethod("MainTest");
IList<CustomAttributeData> data = CustomAttributeData.GetCustomAttributes(t);
}
static Assembly CurrentDomain_ReflectionOnlyAssemblyResolve(object sender, ResolveEventArgs args)
{
return Assembly.ReflectionOnlyLoad(args.Name);
}
source
share